Changed the audited node

This commit is contained in:
cagache
2019-11-08 10:20:16 +02:00
parent 762b6fbd13
commit 100944ac36
2 changed files with 17 additions and 15 deletions

View File

@@ -176,7 +176,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD1); holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD1);
STEP("Check the audit log contains the entry for the add to hold event."); STEP("Check the audit log contains the entry for the add to hold event.");
rmAuditService.checkAuditLogForEvent(getAdminUser(), ADD_TO_HOLD, rmAdmin, HOLD1, rmAuditService.checkAuditLogForEvent(getAdminUser(), ADD_TO_HOLD, rmAdmin, nodeName,
asList(ImmutableMap.of("new", nodeName, "previous", "", "name", "Name"), asList(ImmutableMap.of("new", nodeName, "previous", "", "name", "Name"),
ImmutableMap.of("new", HOLD1, "previous", "", "name", "Hold Name"))); ImmutableMap.of("new", HOLD1, "previous", "", "name", "Hold Name")));
} }
@@ -226,12 +226,11 @@ public class AuditAddToHoldTests extends BaseRMRestTest
STEP("Check the audit log contains only an entry for add to hold."); STEP("Check the audit log contains only an entry for add to hold.");
assertEquals("The list of events should contain only an entry", 1, auditEntries.size()); assertEquals("The list of events should contain only an entry", 1, auditEntries.size());
assertTrue("The list of events should not contain Add to Hold entry for the record", assertTrue("The list of events should not contain Add to Hold entry for the record",
auditEntries.stream().noneMatch(entry -> entry.getChangedValues().contains( auditEntries.stream().noneMatch(entry -> entry.getNodeName().equals(record.getName())));
Collections.singletonList(ImmutableMap.of("new", record.getName(), "previous", "", "name", "Name")))));
} }
/** /**
* Given a document/record/record folder is added to multiple holds * Given a record is added to multiple holds
* When I view the audit log * When I view the audit log
* Then multiple entries have been created in the audit log for each add to hold event * Then multiple entries have been created in the audit log for each add to hold event
*/ */
@@ -252,14 +251,16 @@ public class AuditAddToHoldTests extends BaseRMRestTest
STEP("Check the audit log contains entries for both additions."); STEP("Check the audit log contains entries for both additions.");
assertEquals("The list of events should contain Add to Hold entries for both holds", 2, auditEntries.size()); assertEquals("The list of events should contain Add to Hold entries for both holds", 2, auditEntries.size());
assertTrue("The hold name value for the first add to hold is not audited.", assertTrue("The hold name value for the first add to hold is not audited.",
auditEntries.stream().anyMatch(entry -> entry.getNodeName().equals(HOLD1))); auditEntries.stream().anyMatch(entry -> entry.getChangedValues().contains(
Collections.singletonList(ImmutableMap.of("new", HOLD1, "previous", "", "name", "Hold Name")))));
assertTrue("The hold name value for the second add to hold is not audited.", assertTrue("The hold name value for the second add to hold is not audited.",
auditEntries.stream().anyMatch(entry -> entry.getNodeName().equals(HOLD2))); auditEntries.stream().anyMatch(entry -> entry.getChangedValues().contains(
Collections.singletonList(ImmutableMap.of("new", HOLD2, "previous", "", "name", "Hold Name")))));
} }
/** /**
* Given a document/record/record folder is added to a hold * Given a document is added to a hold
* When I view the audit log as an user with no Read permissions over the hold or the node * When I view the audit log as an user with no Read permissions over the hold or the document
* Then the add to hold entry isn't visible * Then the add to hold entry isn't visible
*/ */
@Test (dataProvider = "invalidUsersForAddToHold") @Test (dataProvider = "invalidUsersForAddToHold")

View File

@@ -187,7 +187,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD3); holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD3);
STEP("Check the audit log contains the entry for the remove from hold event."); STEP("Check the audit log contains the entry for the remove from hold event.");
rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, HOLD3, rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, nodeName,
asList(ImmutableMap.of("new", "", "previous", nodeName, "name", "Name"), asList(ImmutableMap.of("new", "", "previous", nodeName, "name", "Name"),
ImmutableMap.of("new", "", "previous", HOLD3, "name", "Hold Name"))); ImmutableMap.of("new", "", "previous", HOLD3, "name", "Hold Name")));
} }
@@ -210,7 +210,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
holdsAPI.deleteHold(rmAdmin.getUsername(), rmAdmin.getPassword(), DELETED_HOLD); holdsAPI.deleteHold(rmAdmin.getUsername(), rmAdmin.getPassword(), DELETED_HOLD);
STEP("Check the audit log contains the entry for the remove from hold."); STEP("Check the audit log contains the entry for the remove from hold.");
rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, DELETED_HOLD, rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, heldContent.getName(),
asList(ImmutableMap.of("new", "", "previous", heldContent.getName(), "name", "Name"), asList(ImmutableMap.of("new", "", "previous", heldContent.getName(), "name", "Name"),
ImmutableMap.of("new", "", "previous", DELETED_HOLD, "name", "Hold Name"))); ImmutableMap.of("new", "", "previous", DELETED_HOLD, "name", "Hold Name")));
} }
@@ -261,12 +261,11 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
STEP("Check the audit log contains only an entry for remove from hold."); STEP("Check the audit log contains only an entry for remove from hold.");
assertEquals("The list of events should contain only an entry", 1, auditEntries.size()); assertEquals("The list of events should contain only an entry", 1, auditEntries.size());
assertTrue("The list of events should not contain Remove from Hold entry for the record", assertTrue("The list of events should not contain Remove from Hold entry for the record",
auditEntries.stream().noneMatch(entry -> entry.getChangedValues().contains( auditEntries.stream().noneMatch(entry -> entry.getNodeName().equals(record.getName())));
Collections.singletonList(ImmutableMap.of("new", "", "previous", record.getName(), "name", "Name")))));
} }
/** /**
* Given a document/record/record folder is removed from multiple holds * Given a record folder is removed from multiple holds
* When I view the audit log * When I view the audit log
* Then multiple entries have been created in the audit log for each remove from hold event * Then multiple entries have been created in the audit log for each remove from hold event
*/ */
@@ -286,9 +285,11 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
assertEquals("The list of events should contain remove from Hold entries for both holds", 2, assertEquals("The list of events should contain remove from Hold entries for both holds", 2,
auditEntries.size()); auditEntries.size());
assertTrue("The hold name value for the first remove from hold is not audited.", assertTrue("The hold name value for the first remove from hold is not audited.",
auditEntries.stream().anyMatch(entry -> entry.getNodeName().equals(HOLD1))); auditEntries.stream().anyMatch(entry -> entry.getChangedValues().contains(
Collections.singletonList(ImmutableMap.of("new", "", "previous", HOLD1, "name", "Hold Name")))));
assertTrue("The hold name value for the second remove from hold is not audited.", assertTrue("The hold name value for the second remove from hold is not audited.",
auditEntries.stream().anyMatch(entry -> entry.getNodeName().equals(HOLD2))); auditEntries.stream().anyMatch(entry -> entry.getChangedValues().contains(
Collections.singletonList(ImmutableMap.of("new", "", "previous", HOLD2, "name", "Hold Name")))));
} }
/** /**