Skip to content

Commit

Permalink
Fix AuditLog tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michalxo committed Oct 28, 2024
1 parent 2952636 commit e3302b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ static String getArtemisStartingServerVersionString(String version) {

// Audit Log patterns
String LOG_AUDIT_AUTHENTICATION_SUCC_PATTERN = ".* AMQ601715: User %s\\(%s\\)@.* successfully authenticated";
String LOG_AUDIT_AUTHENTICATION_FAIL_PRODUCE_PATTERN = ".* AMQ601264: User %s\\(%s\\).* gets security check failure.*AMQ229032: User: %s does not have permission='SEND' on address %s.*";
String LOG_AUDIT_AUTHENTICATION_FAIL_PRODUCE_PATTERN = ".* AMQ601264: User %s\\(%s\\).* gets security check failure.*(AMQ229213|AMQ229032): User: %s does not have permission='SEND' (for queue %s )?on address %s.*";
String LOG_AUDIT_AUTHENTICATION_FAIL_CONSUME_PATTERN = ".* AMQ601264: User %s\\(%s\\).* gets security check failure.*AMQ229213: User: %s does not have permission='CONSUME' for queue %s on address %s.*";
// 2023-10-18 09:07:00,454 [AUDIT](Thread-12 (activemq-netty-threads)) AMQ601264: User anonymous@192.168.0.2:59866 gets security check failure: ActiveMQSecurityException[errorType=SECURITY_EXCEPTION message=AMQ229213: User: alice does not have permission='CONSUME' for queue myQueue on address myAddress]
String LOG_AUDIT_CREATE_ADDRESS_PATTERN_CORE = ".* AMQ601262: User %s\\(%s\\).* is creating address on target resource:.*with parameters:.*%s::%s.*";
String LOG_AUDIT_CREATE_ADDRESS_PATTERN_AMQP = ".* AMQ601262: User %s\\(%s\\)@.* is creating address on target resource:.* with parameters:.*name=%s.*";
String LOG_AUDIT_CREATE_QUEUE_PATTERN = ".* AMQ601065: User %s\\(%s\\).*is creating a queue on target resource:.*with parameters.* name=myQueue.*address=myAddress.*";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class AuditLogTests extends AbstractSystemTests {
void setupEnv() {
String artemisName = "artemis";
ArtemisConfigData artemisConfigData = new ArtemisConfigData();
String tuneFile;
LOGGER.info("Creating artemis instance: " + artemisName);
if (isMinimumTestVersion(ArtemisVersion.VERSION_2_28)) {
artemisConfigData.withTuneFile("tune.yaml.jinja2");
Expand All @@ -100,7 +99,7 @@ void setupEnv() {

bobFormattedAuth = String.format(ArtemisConstants.LOG_AUDIT_AUTHENTICATION_SUCC_PATTERN, ArtemisConstants.BOB_NAME, ArtemisConstants.ROLE_RECEIVERS);
bobFormattedSent = String.format(ArtemisConstants.LOG_AUDIT_RECEIVED_MESSAGE_PATTERN, ArtemisConstants.BOB_NAME, ArtemisConstants.ROLE_RECEIVERS, queue);
bobFormattedRecv = String.format(ArtemisConstants.LOG_AUDIT_AUTHENTICATION_FAIL_PRODUCE_PATTERN, ArtemisConstants.BOB_NAME, ArtemisConstants.ROLE_RECEIVERS, ArtemisConstants.BOB_NAME, address);
bobFormattedRecv = String.format(ArtemisConstants.LOG_AUDIT_AUTHENTICATION_FAIL_PRODUCE_PATTERN, ArtemisConstants.BOB_NAME, ArtemisConstants.ROLE_RECEIVERS, ArtemisConstants.BOB_NAME, queue, address);
adminFormattedAuth = String.format(ArtemisConstants.LOG_AUDIT_AUTHENTICATION_SUCC_PATTERN, ArtemisConstants.ADMIN_NAME, ArtemisConstants.ROLE_ADMIN);
adminFormattedAddressCore = String.format(ArtemisConstants.LOG_AUDIT_CREATE_ADDRESS_PATTERN_CORE, ArtemisConstants.ADMIN_NAME, ArtemisConstants.ROLE_ADMIN, address, queue);
adminFormattedAddressAmqp = String.format(ArtemisConstants.LOG_AUDIT_CREATE_ADDRESS_PATTERN_AMQP, ArtemisConstants.ADMIN_NAME, ArtemisConstants.ROLE_ADMIN, address, queue);
Expand Down Expand Up @@ -131,8 +130,9 @@ void webConsoleLoginLogoutTest() {

protected void checkAuditLogs(List<String> checkPatternLogs) {
String auditLog = TestUtils.readFileContent(auditLogPath.toFile());
LOGGER.debug("auditLog: {}", auditLog);
LOGGER.trace("auditLog: {}", auditLog);
for (String patternLog : checkPatternLogs) {
LOGGER.debug("Checking audit log: {}", patternLog);
assertThat(auditLog).containsPattern(patternLog);
}
}
Expand Down

0 comments on commit e3302b9

Please sign in to comment.