#!/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 read -ra NODES <<< "${TEST_NODES}" PEOPLE_DN="ou=people,${TEST_SUFFIX}" GROUPS_DN="ou=groups,${TEST_SUFFIX}" ALICE_DN="uid=alice,${PEOPLE_DN}" BOB_DN="uid=bob,${PEOPLE_DN}" CAROL_DN="uid=carol,${PEOPLE_DN}" TEAM_DN="cn=team,${GROUPS_DN}" ldaps_uri() { echo "ldaps://$1:6360" } ldap_uri() { echo "ldap://$1:3890" } FIRST="$(ldaps_uri "${NODES[0]}")" LAST="$(ldaps_uri "${NODES[-1]}")" # nodes for node in "${NODES[@]}"; do eventually has_entry "$(ldaps_uri "${node}")" "${TEST_SUFFIX}" done ok "all nodes are up: ${NODES[*]}" # tls for node in "${NODES[@]}"; do expect_rc 0 bind_search "$(ldap_uri "${node}")" "${ADMIN_DN}" -ZZ -b "${TEST_SUFFIX}" -s base dn expect_rc 13 bind_search "$(ldap_uri "${node}")" "${ADMIN_DN}" -b "${TEST_SUFFIX}" -s base dn done ok "ldaps and StartTLS work, TLS is required" expect_rc 32 ldapsearch -x -H "${FIRST}" -b "${TEST_SUFFIX}" -s base dn ok "anonymous users cannot read the database" # config for node in "${NODES[@]}"; do uri="$(ldaps_uri "${node}")" expect_rc 0 bind_search "${uri}" "${CONFIG_ADMIN_DN}" -b "cn=config" '(olcDatabase=monitor)' olcMonitoring expect_output '^olcMonitoring: TRUE$' expect_rc 0 bind_search "${uri}" "${CONFIG_ADMIN_DN}" -b "cn=module{0},cn=config" -s base olcModuleLoad for module in ${TEST_MODULES}; do expect_output "^olcModuleLoad: \{[0-9]+\}${module}$" done expect_rc 0 bind_search "${uri}" "${CONFIG_ADMIN_DN}" -b "cn=schema,cn=config" -s one cn for schema in ${TEST_SCHEMAS}; do expect_output "^cn: \{[0-9]+\}${schema%.ldif}$" done expect_rc 0 bind_search "${uri}" "${CONFIG_ADMIN_DN}" -b "olcDatabase={1}mdb,cn=config" -s one olcOverlay for overlay in ppolicy unique refint memberof auditlog syncprov; do expect_output "^olcOverlay: \{[0-9]+\}${overlay}$" done expect_output "^olcOverlay: \{5\}syncprov$" expect_rc 0 bind_search "${uri}" "${CONFIG_ADMIN_DN}" -b "cn=config" -s base olcServerID if [ "$(grep -c "^olcServerID: " "${OUTPUT_FILE}")" != "${#NODES[@]}" ]; then cat "${OUTPUT_FILE}" >&2 fail "expected ${#NODES[@]} server IDs on ${node}" fi done ok "config: modules, schemas, overlays and server IDs loaded on all nodes" # data expect_rc 0 bind_modify "${FIRST}" "${ADMIN_DN}" -a < "${OUTPUT_FILE}.member" grep -qi "^member: ${ALICE_DN}$" "${OUTPUT_FILE}.member" && ! grep -qi "^member: ${BOB_DN}$" "${OUTPUT_FILE}.member" } for node in "${NODES[@]}"; do eventually bob_removed_from_team "$(ldaps_uri "${node}")" done ok "deleted users are removed from groups on all nodes" # ppolicy expect_fail ldappasswd -x -H "${FIRST}" -D "${ALICE_DN}" -w "${TEST_PASSWORD}" -a "${TEST_PASSWORD}" -s "short" expect_output "quality|too short|Constraint violation" ok "password policy rejects short clear text passwords" NEW_PASSWORD="Another-passw0rd-2026" expect_rc 0 bind_modify "${FIRST}" "${ALICE_DN}" <