diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java index f63a6efb50..6844a829e0 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java @@ -26,6 +26,7 @@ */ package org.alfresco.rest.v0; +import static org.apache.http.HttpStatus.SC_OK; import static org.testng.Assert.assertTrue; import java.io.UnsupportedEncodingException; @@ -36,6 +37,7 @@ import java.util.List; import org.alfresco.rest.core.v0.BaseAPI; import org.alfresco.rest.rm.community.model.audit.AuditEntry; import org.alfresco.rest.rm.community.util.PojoUtility; +import org.apache.http.HttpResponse; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; @@ -58,6 +60,8 @@ public class RMAuditAPI extends BaseAPI private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog"; private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}"; + private static final String RM_AUDIT_LOG_AS_RECORD = "{0}node/{1}/rmauditlog"; + /** * Returns a list of rm audit entries . * @@ -84,6 +88,21 @@ public class RMAuditAPI extends BaseAPI return PojoUtility.jsonToObject(auditEntries, AuditEntry.class); } + /** + * Returns a list of rm audit entries . + * + * @param user The username of the user to use. + * @param password The password of the user. + * @param size Maximum number of log entries to return + * @return return All return log entries + */ + public List getRMAuditLogAll(String user, String password, final int size) { + String parameters = "size=" + size; + JSONArray auditEntries = doGetRequest(user, password, + MessageFormat.format(RM_AUDIT_LOG_API,"{0}", parameters)).getJSONObject("data").getJSONArray("entries"); + return PojoUtility.jsonToObject(auditEntries, AuditEntry.class); + } + /** * Clear the list of audit entries. * @@ -100,5 +119,19 @@ public class RMAuditAPI extends BaseAPI && getRMAuditLog(username, password, 100, null).size() == 2); } + /** + * Logs the Audit Log as Record. + * + * @param username The username of the user to use. + * @param password The password of the user. + * @param recNodeRef The Record Node reference for which Audit log should be created as record + * @param destinationNodeRef The Folder id Node reference where the html file should be placed + * @throws AssertionError If the API call didn't create the Audit Log as Record. + */ + public HttpResponse logsAuditLogAsRecord(String username, String password, String recNodeRef, String destinationNodeRef) { + JSONObject requestParams = new JSONObject(); + requestParams.put("destination", destinationNodeRef); + return doPostJsonRequest(username, password, SC_OK, requestParams, RM_AUDIT_LOG_AS_RECORD,recNodeRef); + } } diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java index 2d2807a9ed..25f49971b5 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java @@ -97,4 +97,16 @@ public class RecordFoldersAPI extends BaseAPI return null; } + + public HttpResponse reOpenRecordFolder(String user, String password, String recordFolder) + { + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder); + + JSONObject requestParams = new JSONObject(); + requestParams.put("name", "openRecordFolder"); + requestParams.put("nodeRef", recNodeRef); + + return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); + } + } diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java index 037476d52f..f06dfabc61 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java @@ -360,4 +360,25 @@ public class RecordsAPI extends BaseAPI { return getNodeRefSpacesStore() + getItemNodeRef(username, password, recordPath + "/" + recordName); } + + /** + * Reopens the record given as parameter + * + * @param user the user declaring the document as record + * @param password the user's password + * @param recordName the record name + * @return The HTTP Response. + */ + + public HttpResponse reOpenRecord(String user, String password, String recordName) + { + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName); + + JSONObject requestParams = new JSONObject(); + requestParams.put("name", "undeclareRecord"); + requestParams.put("nodeRef", recNodeRef); + + return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); + } + } diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditHoldsTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditHoldsTest.java new file mode 100644 index 0000000000..dd1e7c4ad2 --- /dev/null +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditHoldsTest.java @@ -0,0 +1,146 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rm.community.audit; +import static java.util.Arrays.asList; +import static org.alfresco.rest.rm.community.base.TestData.*; +import static org.alfresco.rest.rm.community.model.audit.AuditEvents.ADD_TO_HOLD; +import static org.alfresco.rest.rm.community.model.audit.AuditEvents.REMOVE_FROM_HOLD; +import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.utility.data.RandomData.getRandomName; +import static org.alfresco.utility.report.log.Step.STEP; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.core.IsNot.not; +import static org.springframework.http.HttpStatus.CREATED; +import static org.testng.AssertJUnit.*; + +import java.util.Collections; +import java.util.List; +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.rest.rm.community.model.audit.AuditEntry; +import org.alfresco.rest.rm.community.model.audit.AuditEvents; +import org.alfresco.rest.rm.community.model.record.Record; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; +import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder; +import org.alfresco.rest.rm.community.model.user.UserRoles; +import org.alfresco.rest.v0.HoldsAPI; +import org.alfresco.rest.v0.service.RMAuditService; +import org.alfresco.rest.v0.service.RoleService; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +public class AuditHoldsTest extends BaseRMRestTest { + private final String PREFIX = generateTestPrefix(AuditAddToHoldTests.class); + private final String HOLD1 = PREFIX + "hold1"; + private SiteModel publicSite; + private FileModel testFile; + @Autowired + private RMAuditService rmAuditService; + @Autowired + private HoldsAPI holdsAPI; + @Autowired + private RoleService roleService; + private UserModel rmAdmin; + private RecordCategory recordCategory; + private RecordCategoryChild recordFolder1,recordFolder2; + private List auditEntries; + private String hold1NodeRef; + public static final String RECORD_FOLDER_THREE = "record-folder-three"; + @BeforeClass(alwaysRun = true) + public void preconditionForAuditAddToHoldTests() + { + createRMSiteIfNotExists(); + rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId); + + STEP("Create a hold"); + hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD1, HOLD_REASON, + HOLD_DESCRIPTION); + + STEP("Create a collaboration site with a test file."); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + testFile = dataContent.usingAdmin().usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + STEP("Create a record category with 2 folders and 1 record"); + recordCategory = createRootCategory(getRandomName("recordCategory")); + recordFolder1 = createRecordFolder(recordCategory.getId(), PREFIX + "recFolder1"); + recordFolder2 = createRecordFolder(recordCategory.getId(), PREFIX + "recFolder2"); + Record recordToBeAdded = createElectronicRecord(recordFolder1.getId(), PREFIX + "record"); + assertStatusCode(CREATED); + + STEP("Add some items to the hold, then remove them from the hold"); + final List itemsList = asList(testFile.getNodeRefWithoutVersion(), recordToBeAdded.getId(), recordFolder2.getId()); + final List holdsList = Collections.singletonList(HOLD1); + holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), recordToBeAdded.getId(), HOLD1); + holdsAPI.removeItemsFromHolds(rmAdmin.getUsername(), rmAdmin.getPassword(), itemsList, holdsList); + + STEP("Delete the record folder that was held"); + getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(recordFolder2.getId()); + + STEP("Rename the parent of the record that was held"); + RecordFolder recordFolder = RecordFolder.builder().name(RECORD_FOLDER_THREE).build(); + getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordFolder1.getId()); + } + /** + * Data provider with hold events that have links to held items + * + * @return the hold events + */ + @DataProvider (name = "holdsEvents") + public Object[][] getHoldEvents() + { + return new AuditEvents[][] + { + { ADD_TO_HOLD }, + { REMOVE_FROM_HOLD } + }; + } + @Test (dataProvider = "holdsEvents") + public void checkItemPathLink(AuditEvents event) { + auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), event); + assertFalse("Audit results should not be empty",auditEntries.size()==0); + final String auditedEvent = event + " - " + testFile.getName(); + assertTrue("Audit results should contain one " + auditedEvent + " event",auditEntries.stream().anyMatch(e -> e.getEvent().startsWith(event.eventDisplayName))); + STEP("Check the audit log contains only an entry for add to hold."); + assertThat(auditEntries, is(not(empty()))); + } + @AfterClass(alwaysRun = true) + private void cleanup() { + dataSite.usingAdmin().deleteSite(publicSite); + deleteRecordFolder(recordFolder1.getId()); + deleteRecordFolder(recordFolder2.getId()); + deleteRecordCategory(recordCategory.getId()); + rmAuditService.clearAuditLog(); + } +} diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/ElectronicRecordAuditLogTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/ElectronicRecordAuditLogTest.java new file mode 100644 index 0000000000..a868c188c8 --- /dev/null +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/ElectronicRecordAuditLogTest.java @@ -0,0 +1,244 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rm.community.audit; + +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.rest.rm.community.model.audit.AuditEntry; +import org.alfresco.rest.rm.community.model.record.Record; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; +import org.alfresco.rest.v0.RMAuditAPI; +import org.alfresco.rest.v0.RMRolesAndActionsAPI; +import org.alfresco.rest.v0.RecordsAPI; +import org.alfresco.test.AlfrescoTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.UserModel; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD; +import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.test.util.AssertionErrors.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.fail; + +public class ElectronicRecordAuditLogTest extends BaseRMRestTest { + + private Optional rmAdmin; + @Autowired + private RMRolesAndActionsAPI rmRolesAndActionsAPI; + @Autowired + private RMAuditAPI auditLog; + @Autowired + private RecordsAPI recordApi; + /* electronic record details */ + private static final String AUDIT_ELECTRONIC_RECORD = generateTestPrefix(ElectronicRecordAuditLogTest.class) + "electronic record"; + private static final String AUDIT_COMPLETE_REOPEN_ELECTRONIC_RECORD = "Complete Reopen Electronic Record"; + public static final String TITLE = "Title"; + public static final String DESCRIPTION = "Description"; + private RecordCategory category1; + private RecordCategoryChild recordFolder1; + private Record electronicRecord, electronicRecord2; + + @BeforeClass(alwaysRun = true) + public void electronicRecordsAuditLogSetup() + { + createRMSiteIfNotExists(); + rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser()); + rmRolesAndActionsAPI.assignRoleToUser( + getDataUser().usingAdmin().getAdminUser().getUsername(), + getDataUser().usingAdmin().getAdminUser().getPassword(), + rmAdmin.get().getUsername(), + "Administrator"); + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + category1 = createRootCategory(TITLE, DESCRIPTION); + recordFolder1 = createFolder(category1.getId(),TITLE); + + electronicRecord = createElectronicRecord(recordFolder1.getId(),AUDIT_ELECTRONIC_RECORD,rmAdmin.get()); + } + + @Test(description = "Audit log for newly filed electronic record") + @AlfrescoTest(jira="RM-4303") + public void newElectronicRecordAudit() { + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + + // newly created record contains 2 events: "file to" and metadata update + // the order in which object creation and metadata update are listed isn't always identical due to + // both happening in the same transaction + assertTrue("File To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("File to"))); + assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + } + + @Test + ( + dependsOnMethods = "newElectronicRecordAudit", + description = "Viewing electronic record audit log is itself an auditable event" + ) + @AlfrescoTest(jira="RM-4303") + public void electronicRecordAuditIsEvent() + { + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Audit View Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View"))); + } + + @Test + ( + dependsOnMethods = "electronicRecordAuditIsEvent", + description = "Rename electronic record is an edit metadata event" + ) + @AlfrescoTest(jira="RM-4303") + public void renameElectronicRecord() { + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + Record renameElectronicRecord = createRecordModel("edited " + electronicRecord.getName(), "", ""); + + // rename record + getRestAPIFactory().getRecordsAPI().updateRecord(renameElectronicRecord, electronicRecord.getId()); + assertStatusCode(OK); + + // we expect 1 new event: "metadata update" + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + } + + @Test ( + dependsOnMethods = "newElectronicRecordAudit", + description = "Complete and reopen electronic record") + @AlfrescoTest(jira="RM-4303") + public void completeAndReopenElectronicRecord() { + electronicRecord2 = createElectronicRecord(recordFolder1.getId(),AUDIT_COMPLETE_REOPEN_ELECTRONIC_RECORD); + + // complete record + recordApi.completeRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(), + electronicRecord2.getName()); + + try + { + Utility.sleep(1000, 30000, () -> + { + org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + List aspects = recordsAPI.getRecord(electronicRecord2.getId()).getAspectNames(); + // a record must be completed + assertTrue("Record is not completed.",aspects.contains(ASPECTS_COMPLETED_RECORD)); + }); + } + catch (InterruptedException e) + { + fail("InterruptedException received while waiting for results."); + } + + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Complete Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Complete Record"))); + + // Reopen record + recordApi.reOpenRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(), + electronicRecord2.getName()); + + try + { + Utility.sleep(1000, 30000, () -> + { + org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + List aspects = recordsAPI.getRecord(electronicRecord2.getId()).getAspectNames(); + // a record mustn't be completed + assertFalse(aspects.contains(ASPECTS_COMPLETED_RECORD)); + }); + } + catch (InterruptedException e) + { + fail("InterruptedException received while waiting for results."); + } + + auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Reopen Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Reopen Record"))); + } + + @Test + ( + dependsOnMethods = "completeAndReopenElectronicRecord", + description = "File electronic record's audit log as record" + ) + @AlfrescoTest(jira="RM-4303") + public void fileElectronicRecordAuditLogAsRecord() + { + // audit log is stored in the same folder, refresh it so that it appears in the list + HttpResponse auditRecordHttpResponse = auditLog.logsAuditLogAsRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(), + getRecordNodeRef(electronicRecord2.getId()),getFolderNodeRef(recordFolder1.getId())); + JSONObject auditRecordProperties = getAuditPropertyValues(auditRecordHttpResponse); + Record auditRecord = getRestAPIFactory().getRecordsAPI().getRecord(auditRecordProperties.get("record").toString() + .replace("workspace://SpacesStore/","")); + // check audit log + AssertJUnit.assertTrue(auditRecordProperties.get("recordName").toString().endsWith(".html")); + AssertJUnit.assertTrue(auditRecord.getAspectNames().stream().noneMatch(x -> x.startsWith(ASPECTS_COMPLETED_RECORD))); + } + + private String getFolderNodeRef(String folderId) { + return "workspace://SpacesStore/" + folderId; + } + + private String getRecordNodeRef(String recordId) { + return "workspace/SpacesStore/" + recordId; + } + + private JSONObject getAuditPropertyValues(HttpResponse httpResponse) { + HttpEntity entity = httpResponse.getEntity(); + String responseString = null; + try { + responseString = EntityUtils.toString(entity, "UTF-8"); + } catch (IOException e) { + throw new RuntimeException(e); + } + JSONObject result = new JSONObject(responseString); + return result; + } + + @AfterMethod + private void closeAuditLog() { + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + } + + @AfterClass(alwaysRun = true) + private void electronicRecordAuditLogCleanup() { + deleteRecord(electronicRecord.getId()); + deleteRecordFolder(recordFolder1.getId()); + deleteRecordCategory(category1.getId()); + dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword())); + } +} \ No newline at end of file diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/NonElectronicRecordAuditLogTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/NonElectronicRecordAuditLogTest.java new file mode 100644 index 0000000000..8b5d6d0c2d --- /dev/null +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/NonElectronicRecordAuditLogTest.java @@ -0,0 +1,246 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rm.community.audit; + +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.rest.rm.community.model.audit.AuditEntry; +import org.alfresco.rest.rm.community.model.record.Record; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; +import org.alfresco.rest.v0.RMAuditAPI; +import org.alfresco.rest.v0.RMRolesAndActionsAPI; +import org.alfresco.rest.v0.RecordsAPI; +import org.alfresco.test.AlfrescoTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.UserModel; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD; +import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.test.util.AssertionErrors.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.fail; + + +public class NonElectronicRecordAuditLogTest extends BaseRMRestTest { + private Optional rmAdmin; + @Autowired + private RMRolesAndActionsAPI rmRolesAndActionsAPI; + @Autowired + private RMAuditAPI auditLog; + @Autowired + private RecordsAPI recordApi; + private RecordCategory category1; + private RecordCategoryChild recordFolder1; + private Record nonElectronicRecord , nonElectronicRecord2; + private static final String AUDIT_NON_ELECTRONIC_RECORD = generateTestPrefix(NonElectronicRecordAuditLogTest.class) + "non electronic record"; + private static final String AUDIT_COMPLETE_REOPEN_NON_ELECTRONIC_RECORD = "Complete Reopen Non-Electronic Record"; + public static final String TITLE = "Title"; + public static final String DESCRIPTION = "Description"; + + @BeforeClass(alwaysRun = true) + public void nonElectronicRecordAuditLogSetup() + { + createRMSiteIfNotExists(); + rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser()); + rmRolesAndActionsAPI.assignRoleToUser( + getDataUser().usingAdmin().getAdminUser().getUsername(), + getDataUser().usingAdmin().getAdminUser().getPassword(), + rmAdmin.get().getUsername(), + "Administrator"); + + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + category1 = createRootCategory(TITLE, DESCRIPTION); + recordFolder1 = createFolder(category1.getId(),TITLE); + nonElectronicRecord = createNonElectronicRecord(recordFolder1.getId(),AUDIT_NON_ELECTRONIC_RECORD,rmAdmin.get()); + + } + + @Test(description = "Audit log for newly filed non-electronic record") + @AlfrescoTest(jira="RM-4303") + public void newNonElectronicRecordAudit() + { + + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + + // newly created record contains 3 events: "created object", "file to" and metadata update + assertTrue("File To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("File to"))); + assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + assertTrue("Created Object Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object"))); + } + + @Test + ( + dependsOnMethods = "newNonElectronicRecordAudit", + description = "Viewing Non electronic record audit log is itself an auditable event" + ) + @AlfrescoTest(jira="RM-4303") + public void nonElectronicRecordAuditIsEvent() + { + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Audit View Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View"))); + + } + + @Test + ( + dependsOnMethods = "nonElectronicRecordAuditIsEvent", + description = "Rename electronic record is an edit metadata event" + ) + @AlfrescoTest(jira="RM-4303") + public void renameNonElectronicRecord() + { + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + Record renameNonElectronicRecord = createRecordModel("edited " + nonElectronicRecord.getName(), "", ""); + + // rename record + getRestAPIFactory().getRecordsAPI().updateRecord(renameNonElectronicRecord, nonElectronicRecord.getId()); + assertStatusCode(OK); + + // we expect 1 new event: "metadata update" + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + + } + + @Test (dependsOnMethods = "newNonElectronicRecordAudit",description = "Complete and reopen electronic record") + @AlfrescoTest(jira="RM-4303") + public void completeAndReopenNonElectronicRecord() + { + nonElectronicRecord2 = createNonElectronicRecord(recordFolder1.getId(),AUDIT_COMPLETE_REOPEN_NON_ELECTRONIC_RECORD); + + // complete record + recordApi.completeRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(), + nonElectronicRecord2.getName()); + + try + { + Utility.sleep(1000, 30000, () -> + { + org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + List aspects = recordsAPI.getRecord(nonElectronicRecord2.getId()).getAspectNames(); + // a record must be completed + assertTrue("Record is not completed.",aspects.contains(ASPECTS_COMPLETED_RECORD)); + }); + } + catch (InterruptedException e) + { + fail("InterruptedException received while waiting for results."); + } + + List auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Complete Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Complete Record"))); + + // Reopen record + recordApi.reOpenRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(), + nonElectronicRecord2.getName()); + + try + { + Utility.sleep(1000, 30000, () -> + { + org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + List aspects = recordsAPI.getRecord(nonElectronicRecord2.getId()).getAspectNames(); + // a record mustn't be completed + assertFalse(aspects.contains(ASPECTS_COMPLETED_RECORD)); + }); + } + catch (InterruptedException e) + { + fail("InterruptedException received while waiting for results."); + } + + auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100); + assertTrue("Reopen Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Reopen Record"))); + + } + @Test + ( + dependsOnMethods = "completeAndReopenNonElectronicRecord", + description = "File electronic record's audit log as record" + ) + @AlfrescoTest(jira="RM-4303") + public void fileNonElectronicRecordAuditLogAsRecord() + { + // audit log is stored in the same folder, refresh it so that it appears in the list + HttpResponse auditRecordHttpResponse = auditLog.logsAuditLogAsRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(), + getRecordNodeRef(nonElectronicRecord2.getId()),getFolderNodeRef(recordFolder1.getId())); + JSONObject auditRecordProperties = getAuditPropertyValues(auditRecordHttpResponse); + Record auditRecord = getRestAPIFactory().getRecordsAPI().getRecord(auditRecordProperties.get("record").toString() + .replace("workspace://SpacesStore/","")); + // check audit log + AssertJUnit.assertTrue(auditRecordProperties.get("recordName").toString().endsWith(".html")); + AssertJUnit.assertTrue(auditRecord.getAspectNames().stream().noneMatch(x -> x.startsWith(ASPECTS_COMPLETED_RECORD))); + + } + + private String getFolderNodeRef(String folderId) { + return "workspace://SpacesStore/" + folderId; + } + + private String getRecordNodeRef(String recordId) { + return "workspace/SpacesStore/" + recordId; + } + + private JSONObject getAuditPropertyValues(HttpResponse httpResponse) { + HttpEntity entity = httpResponse.getEntity(); + String responseString = null; + try { + responseString = EntityUtils.toString(entity, "UTF-8"); + } catch (IOException e) { + throw new RuntimeException(e); + } + JSONObject result = new JSONObject(responseString); + return result; + } + @AfterMethod + private void closeAuditLog() { + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + } + + @AfterClass(alwaysRun = true) + private void nonElectronicRecordAuditLogCleanup() { + deleteRecord(nonElectronicRecord.getId()); + deleteRecord(nonElectronicRecord2.getId()); + deleteRecordFolder(recordFolder1.getId()); + deleteRecordCategory(category1.getId()); + dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword())); + } +} diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/RecordCategoryAuditLogTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/RecordCategoryAuditLogTest.java new file mode 100644 index 0000000000..f2ec8562d0 --- /dev/null +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/RecordCategoryAuditLogTest.java @@ -0,0 +1,120 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rm.community.audit; + +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.rest.rm.community.model.audit.AuditEntry; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.v0.RMAuditAPI; +import org.alfresco.rest.v0.RMRolesAndActionsAPI; +import org.alfresco.test.AlfrescoTest; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; +import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; +import static org.alfresco.utility.report.log.Step.STEP; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.test.util.AssertionErrors.assertTrue; + +public class RecordCategoryAuditLogTest extends BaseRMRestTest { + @Autowired + private RMRolesAndActionsAPI rmRolesAndActionsAPI; + @Autowired + private RMAuditAPI auditLog; + + private final String TEST_PREFIX = generateTestPrefix(RecordCategoryAuditLogTest.class); + private final String RM_ADMIN = TEST_PREFIX + "rm_admin"; + private static final String AUDIT_CATEGORY = generateTestPrefix(RecordCategoryAuditLogTest.class) + "category"; + private RecordCategory recordCategoryAudit; + + @BeforeClass(alwaysRun = true) + public void recordCategoryAuditLogSetup() { + STEP("Create RM Site"); + createRMSiteIfNotExists(); + + STEP("Create RM Admin user"); + rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN, + getAdminUser().getPassword(), + "Administrator"); + } + + @Test + @AlfrescoTest(jira = "RM-2768") + public void recordCategoryAudit() throws Exception { + STEP("Create root level category"); + recordCategoryAudit = createRootCategory(AUDIT_CATEGORY); + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + // newly created record category contains 3 events: object creation, inherited permissions set to false and metadata update + // the order in which object creation and metadata update are listed isn't always identical due to + // both happening in the same transaction + assertTrue("Created Object Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object"))); + assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + } + + @Test + ( + dependsOnMethods = "recordCategoryAudit", + description = "Viewing audit log is itself an auditable event" + ) + @AlfrescoTest(jira="RM-4303") + public void recordCategoryAuditIsEvent() { + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + assertTrue("Audit View Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View"))); + } + + @Test + ( + dependsOnMethods = "recordCategoryAuditIsEvent", + description = "Record category rename is an edit metadata event" + ) + @AlfrescoTest(jira="RM-4303") + public void renameRecordCategory() { + String categoryName = "Category name " + getRandomAlphanumeric(); + RecordCategory rootRecordCategory = createRootCategory(categoryName); + String newCategoryName = "Rename " + categoryName; + RecordCategory recordCategoryUpdated = RecordCategory.builder().name(newCategoryName).build(); + RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated, rootRecordCategory.getId()); + + assertStatusCode(OK); + // we expect 1 new event: "metadata update" + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + } + @AfterClass(alwaysRun = true) + private void electronicRecordAuditLogCleanup() { + deleteRecordCategory(recordCategoryAudit.getId()); + dataUser.deleteUser(new UserModel(RM_ADMIN, + getAdminUser().getPassword())); + auditLog.clearAuditLog(getAdminUser().getUsername(), getAdminUser().getPassword()); + } +} + diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/RecordFolderAuditLogTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/RecordFolderAuditLogTest.java new file mode 100644 index 0000000000..f8bf2e2686 --- /dev/null +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/RecordFolderAuditLogTest.java @@ -0,0 +1,175 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rm.community.audit; + +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.rest.rm.community.model.audit.AuditEntry; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; +import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder; +import org.alfresco.rest.v0.RMAuditAPI; +import org.alfresco.rest.v0.RMRolesAndActionsAPI; +import org.alfresco.rest.v0.RecordFoldersAPI; +import org.alfresco.test.AlfrescoTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import java.util.List; +import java.util.Optional; + +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordFolderModel; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.test.util.AssertionErrors.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.fail; + +public class RecordFolderAuditLogTest extends BaseRMRestTest { + + private Optional rmAdmin; + @Autowired + private RMRolesAndActionsAPI rmRolesAndActionsAPI; + @Autowired + private RMAuditAPI auditLog; + + @Autowired + private RecordFoldersAPI recordFoldersAPI; + private RecordCategory category1; + private RecordCategoryChild recordFolder1; + public static final String TITLE = "Title"; + public static final String DESCRIPTION = "Description"; + + @BeforeClass(alwaysRun = true) + public void recordFolderAuditLogSetup() { + createRMSiteIfNotExists(); + rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser()); + rmRolesAndActionsAPI.assignRoleToUser( + getDataUser().usingAdmin().getAdminUser().getUsername(), + getDataUser().usingAdmin().getAdminUser().getPassword(), + rmAdmin.get().getUsername(), + "Administrator"); + } + + @Test(description = "Audit log for empty record folder") + @AlfrescoTest(jira = "RM-4303") + public void recordFolderAudit() { + category1 = createRootCategory(TITLE, DESCRIPTION); + recordFolder1 = createFolder(category1.getId(), TITLE); + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + assertTrue("Created Object Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object"))); + assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + + } + + @Test + ( + dependsOnMethods = "recordFolderAudit", + description = "Viewing record folder audit log is itself an auditable event" + ) + @AlfrescoTest(jira = "RM-4303") + public void recordFolderAuditIsEvent() { + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + assertTrue("Audit View Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View"))); + + } + + @Test + ( + dependsOnMethods = "recordFolderAuditIsEvent", + description = "Record folder rename is an edit metadata event" + ) + @AlfrescoTest(jira = "RM-4303") + public void renameRecordFolder() { + auditLog.clearAuditLog(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()); + RecordFolder renameRecordFolder = createRecordFolderModel(category1.getId(), "edited"); + getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(renameRecordFolder, recordFolder1.getId()); + assertStatusCode(OK); + // we expect 1 new event: "metadata update" + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); +// assertTrue("Move To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Move to"))); + assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata"))); + + } + + @Test(dependsOnMethods = "recordFolderAudit", + description = "Close and reopen folder") + @AlfrescoTest(jira = "RM-4303") + public void closeReopenFolder() { + //close folder + recordFoldersAPI.closeRecordFolder(rmAdmin.get().getUsername(), rmAdmin.get().getPassword(), + recordFolder1.getName()); + try + { + Utility.sleep(1000, 30000, () -> + { + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + assertTrue("Folder Close Record Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Close Record Folder"))); + + }); + } + catch (InterruptedException e) + { + fail("InterruptedException received while waiting for results."); + } + + //reopen folder + recordFoldersAPI.reOpenRecordFolder(rmAdmin.get().getUsername(), rmAdmin.get().getPassword(), + recordFolder1.getName()); + try + { + Utility.sleep(1000, 30000, () -> + { + + List auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100); + assertTrue("Reopen Record Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Open Record Folder"))); + + }); + } + catch (InterruptedException e) + { + fail("InterruptedException received while waiting for results."); + } + } + @AfterMethod + private void closeAuditLog() + { + auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword()); + } + + @AfterClass (alwaysRun = true) + public void recordFolderAuditLogCleanup() + { + deleteRecordFolder(recordFolder1.getId()); + deleteRecordCategory(category1.getId()); + dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword())); + } + +}