#!/bin/bash set -euo pipefail # if container log level is trace: # print commands and their arguments as they are executed container log level eq trace && set -x # shellcheck disable=SC1091 source /tmp/openldap-test-lib.sh URI="ldap://127.0.0.1:3890" USER_DN="uid=audit-user,${TEST_SUFFIX}" RENAMED_DN="uid=audited-user,${TEST_SUFFIX}" LOG_FILE="${TEST_AUDITLOG_FILE}" if ! container --log-level debug --skip-process > /tmp/openldap-auditlog-bootstrap.log 2>&1; then tail -60 /tmp/openldap-auditlog-bootstrap.log exit 1 fi start_ldap() { slapd -F /etc/openldap/slapd.d -h "${URI}" -d 0 > /tmp/openldap-auditlog-slapd.log 2>&1 & SLAPD_PID=$! eventually has_entry "${URI}" "${TEST_SUFFIX}" } stop_ldap() { kill "${SLAPD_PID}" wait "${SLAPD_PID}" } trap 'kill "${SLAPD_PID}" 2>/dev/null || true' EXIT start_ldap expect_rc 0 bind_search "${URI}" "${CONFIG_ADMIN_DN}" \ -b 'cn=module{0},cn=config' -s base olcModuleLoad if [ "${TEST_AUDITLOG_MODE}" = "default" ]; then expect_no_output 'auditlog\.so' else expect_output 'auditlog\.so$' fi expect_rc 0 bind_search "${URI}" "${CONFIG_ADMIN_DN}" \ -b 'olcDatabase={1}mdb,cn=config' '(objectClass=olcAuditLogConfig)' olcAuditlogFile if [ "${TEST_AUDITLOG_MODE}" = "default" ]; then expect_no_output '^olcAuditlogFile:' else expect_output "^olcAuditlogFile: \"?${LOG_FILE}\"?$" fi expect_rc 0 bind_modify "${URI}" "${ADMIN_DN}" -a <