From 3a78d9180f1f1c66200cf094b70dfd1b566b3777 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 11:29:01 +0200 Subject: [PATCH] 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(); + } + +}