From a98ac379c0ad6f25db25067094e79fabaed0b07e Mon Sep 17 00:00:00 2001 From: rodicasutu Date: Mon, 15 Mar 2021 10:55:52 +0200 Subject: [PATCH 1/6] add a test for filtering audit by login successfully --- .../rm/community/model/audit/AuditEvents.java | 1 + .../audit/AuditLoginEventsTests.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java index b844ad6dab..7b9381040f 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java @@ -42,6 +42,7 @@ public enum AuditEvents ADD_TO_USER_GROUP("Add To User Group", "Add To User Group"), REMOVE_FROM_USER_GROUP("Remove From User Group", "Remove From User Group"), LOGIN_UNSUCCESSFUL("Login.Failure", "Login Unsuccessful"), + LOGIN_SUCCESSFUL("Login.Success", "Login Successful"), CREATE_HOLD("Create Hold", "Create Hold"), DELETE_HOLD("Delete Hold", "Delete Hold"), ADD_TO_HOLD("Add To Hold", "Add To Hold"), diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java index 25a32e52d5..c93fa87d30 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java @@ -26,6 +26,7 @@ */ package org.alfresco.rest.rm.community.audit; +import static org.alfresco.rest.rm.community.model.audit.AuditEvents.LOGIN_SUCCESSFUL; import static org.alfresco.rest.rm.community.model.audit.AuditEvents.LOGIN_UNSUCCESSFUL; import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.AssertJUnit.assertTrue; @@ -72,4 +73,24 @@ public class AuditLoginEventsTests extends BaseRMRestTest assertTrue("The list of events is not filtered by " + LOGIN_UNSUCCESSFUL.event, auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(LOGIN_UNSUCCESSFUL.eventDisplayName))); } + /** + * Given I have tried to login using valid credentials + * When I view the RM audit filtered by Login successful event + * Then the audit log contains only the entries for the Login successful event + */ + @Test + public void filterByLoginSuccessful() throws Exception + { + rmAuditService.clearAuditLog(); + restClient.authenticateUser(getAdminUser()); + restClient.withCoreAPI().getSites(); + + STEP("Get the list of audit entries for the login unsuccessful event."); + List auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), + LOGIN_SUCCESSFUL); + + STEP("Check the audit log contains only the entries for the login unsuccessful event."); + assertTrue("The list of events is not filtered by " + LOGIN_SUCCESSFUL.event, + auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(LOGIN_SUCCESSFUL.eventDisplayName))); + } } From de2a19fc414f40863fa75f0b0396f896c1f53bac Mon Sep 17 00:00:00 2001 From: rodicasutu Date: Mon, 15 Mar 2021 10:59:07 +0200 Subject: [PATCH 2/6] run the filter by login successfully at the end --- .../src/test/resources/testng.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml b/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml index dffe3b393c..0b52503f2c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml +++ b/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml @@ -1,9 +1,13 @@ - + + + + + \ No newline at end of file From 84bc67c939f10c406ddad6ae470b2767beb96fb3 Mon Sep 17 00:00:00 2001 From: rodicasutu Date: Tue, 16 Mar 2021 14:51:13 +0200 Subject: [PATCH 3/6] remove the clean up of the audit to check if the test is failing --- .../alfresco/rest/rm/community/audit/AuditLoginEventsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java index c93fa87d30..2cbf62fedc 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java @@ -81,7 +81,7 @@ public class AuditLoginEventsTests extends BaseRMRestTest @Test public void filterByLoginSuccessful() throws Exception { - rmAuditService.clearAuditLog(); + //rmAuditService.clearAuditLog(); restClient.authenticateUser(getAdminUser()); restClient.withCoreAPI().getSites(); From a4dbb6b60569571e01f7ef30f4cb3f752235ea7e Mon Sep 17 00:00:00 2001 From: rodicasutu Date: Wed, 17 Mar 2021 14:25:28 +0200 Subject: [PATCH 4/6] add a test suite for the attempt of reproducing the filter by login success event issue --- .../src/test/resources/log4j.properties | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties b/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties index e01a70def8..fcf7b84121 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties +++ b/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties @@ -1,5 +1,5 @@ # Root logger option -log4j.rootLogger=INFO, file +log4j.rootLogger=INFO, file, stdout # Direct log messages to a log file log4j.appender.file=org.apache.log4j.RollingFileAppender @@ -9,3 +9,8 @@ log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n log4j.logger.com.example=debug +##Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n From fdf9f04c24fdd81f544da3cd02b36d2ce15e1205 Mon Sep 17 00:00:00 2001 From: rodicasutu Date: Tue, 23 Mar 2021 10:27:10 +0200 Subject: [PATCH 5/6] revert unnecessary changes --- .../rest/rm/community/audit/AuditLoginEventsTests.java | 6 +++--- .../src/test/resources/log4j.properties | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java index 2cbf62fedc..02f40b5c2e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditLoginEventsTests.java @@ -73,6 +73,7 @@ public class AuditLoginEventsTests extends BaseRMRestTest assertTrue("The list of events is not filtered by " + LOGIN_UNSUCCESSFUL.event, auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(LOGIN_UNSUCCESSFUL.eventDisplayName))); } + /** * Given I have tried to login using valid credentials * When I view the RM audit filtered by Login successful event @@ -81,15 +82,14 @@ public class AuditLoginEventsTests extends BaseRMRestTest @Test public void filterByLoginSuccessful() throws Exception { - //rmAuditService.clearAuditLog(); restClient.authenticateUser(getAdminUser()); restClient.withCoreAPI().getSites(); - STEP("Get the list of audit entries for the login unsuccessful event."); + STEP("Get the list of audit entries for the login successful event."); List auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), LOGIN_SUCCESSFUL); - STEP("Check the audit log contains only the entries for the login unsuccessful event."); + STEP("Check the audit log contains only the entries for the login successful event."); assertTrue("The list of events is not filtered by " + LOGIN_SUCCESSFUL.event, auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(LOGIN_SUCCESSFUL.eventDisplayName))); } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties b/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties index fcf7b84121..e01a70def8 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties +++ b/rm-automation/rm-automation-community-rest-api/src/test/resources/log4j.properties @@ -1,5 +1,5 @@ # Root logger option -log4j.rootLogger=INFO, file, stdout +log4j.rootLogger=INFO, file # Direct log messages to a log file log4j.appender.file=org.apache.log4j.RollingFileAppender @@ -9,8 +9,3 @@ log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n log4j.logger.com.example=debug -##Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n From 506e9743bc048d60887e324a3043ecdceba27267 Mon Sep 17 00:00:00 2001 From: rodicasutu Date: Mon, 29 Mar 2021 09:58:18 +0300 Subject: [PATCH 6/6] Revert "run the filter by login successfully at the end" This reverts commit de2a19fc --- .../src/test/resources/testng.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml b/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml index 0b52503f2c..dffe3b393c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml +++ b/rm-automation/rm-automation-community-rest-api/src/test/resources/testng.xml @@ -1,13 +1,9 @@ - + - - - - \ No newline at end of file