From aeb1fe90ce87b01735180c3bace0f87631afd508 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 12:19:43 +0200 Subject: [PATCH] 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); + } + +}