From 05fe676459248ea60b63a362b7e27c70df310990 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Thu, 20 Jul 2017 14:48:47 +0300 Subject: [PATCH] REPO-2644 : REST API: Delete Application Audit Entries - add TAS-level sanity test Add TAS test for deleting audit application entries. --- .../rest/audit/DeleteAuditCoreTests.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java index 6475ee4c8..30dd2b244 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.audit; +import static org.testng.Assert.assertEquals; + import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -26,11 +28,35 @@ public class DeleteAuditCoreTests extends AuditTest restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting a set of audit entries for an application is only for admin user, and status code is 204") + public void deleteAuditEntriesForAnAuditApplication() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=4").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + String firstId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + String secondId = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + + restClient.authenticateUser(userModel).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(restAuditEntryCollection.getPagination().getCount(), 0); + } + }