From 08ea124a2bb986bbe442098922d461474f8d063a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 5 Dec 2016 18:58:47 +0200 Subject: [PATCH 01/17] 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 3370e3062c3a0eb659bf869477dfded69a28899b Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 6 Dec 2016 12:26:39 +0200 Subject: [PATCH 02/17] 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 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 03/17] 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 ee926d81cd857d7b58d98567c12f240337be1a0d Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Wed, 7 Dec 2016 16:38:14 +0200 Subject: [PATCH 04/17] 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 8c281011a51f95537bc22cc0450952a7f2d0bd30 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 8 Dec 2016 09:36:18 +0200 Subject: [PATCH 05/17] 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 06/17] 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 d58bd126866ec13304923e30ae482de4fedbd761 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 8 Dec 2016 10:30:39 +0200 Subject: [PATCH 07/17] 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 7d7e4c04ec5e2090887faa166e45f10b2607bf18 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 11:05:12 +0200 Subject: [PATCH 08/17] 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 09/17] 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 10/17] 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 11/17] 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 12/17] 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 13/17] 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 14/17] 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 15/17] 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 16/17] 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 17/17] 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");