From 60584d21421216681766b8ae2643f5d17ee3f89f Mon Sep 17 00:00:00 2001 From: alinmear Date: Fri, 17 Feb 2017 20:57:16 +0100 Subject: [PATCH] Add additional unit tests for postfix ldap integration * check custom configs copied * check environment variables substituted --- test/config/ldap-aliases.cf | 9 +++++++++ test/config/ldap-groups.cf | 9 +++++++++ test/config/ldap-users.cf | 9 +++++++++ test/tests.bats | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 test/config/ldap-aliases.cf create mode 100644 test/config/ldap-groups.cf create mode 100644 test/config/ldap-users.cf diff --git a/test/config/ldap-aliases.cf b/test/config/ldap-aliases.cf new file mode 100644 index 00000000..f51f2d08 --- /dev/null +++ b/test/config/ldap-aliases.cf @@ -0,0 +1,9 @@ +# Testconfig for ldap integration +bind = yes +bind_dn = cn=admin,dc=domain,dc=com +bind_pw = admin +query_filter = (&(mailAlias=%s)(mailEnabled=TRUE)) +result_attribute = mail +search_base = ou=people,dc=domain,dc=com +server_host = mail.domain.com +version = 3 diff --git a/test/config/ldap-groups.cf b/test/config/ldap-groups.cf new file mode 100644 index 00000000..b51d96c6 --- /dev/null +++ b/test/config/ldap-groups.cf @@ -0,0 +1,9 @@ +# Testconfig for ldap integration +bind = yes +bind_dn = cn=admin,dc=domain,dc=com +bind_pw = admin +query_filter = (&(mailGroupMember=%s)(mailEnabled=TRUE)) +result_attribute = mail +search_base = ou=people,dc=domain,dc=com +server_host = mail.domain.com +version = 3 diff --git a/test/config/ldap-users.cf b/test/config/ldap-users.cf new file mode 100644 index 00000000..fa915ccb --- /dev/null +++ b/test/config/ldap-users.cf @@ -0,0 +1,9 @@ +# Testconfig for ldap integration +bind = yes +bind_dn = cn=admin,dc=domain,dc=com +bind_pw = admin +query_filter = (&(mail=%s)(mailEnabled=TRUE)) +result_attribute = mail +search_base = ou=people,dc=domain,dc=com +server_host = mail.domain.com +version = 3 diff --git a/test/tests.bats b/test/tests.bats index 1cd3538d..e1cef6b6 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -960,6 +960,38 @@ load 'test_helper/bats-assert/load' assert_output "some.user@localhost.localdomain" } +@test "checking postfix: ldap custom config files copied" { + run docker exec mail_with_ldap /bin/sh -c "grep "# Testconfig for ldap integration" /etc/postfix/ldap-users.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep "# Testconfig for ldap integration" /etc/postfix/ldap-groups.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep "# Testconfig for ldap integration" /etc/postfix/ldap-aliases.cf" + assert_success +} + +@test "checking postfix: ldap config overwrites success" { + run docker exec mail_with_ldap /bin/sh -c "grep 'server_host = ldap' /etc/postfix/ldap-users.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep 'search_base = ou=people,dc=localhost,dc=localdomain' /etc/postfix/ldap-users.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep 'bind_dn = cn=admin,dc=localhost,dc=localdomain' /etc/postfix/ldap-users.cf" + assert_success + + run docker exec mail_with_ldap /bin/sh -c "grep 'server_host = ldap' /etc/postfix/ldap-groups.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep 'search_base = ou=people,dc=localhost,dc=localdomain' /etc/postfix/ldap-groups.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep 'bind_dn = cn=admin,dc=localhost,dc=localdomain' /etc/postfix/ldap-groups.cf" + assert_success + + run docker exec mail_with_ldap /bin/sh -c "grep 'server_host = ldap' /etc/postfix/ldap-aliases.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep 'search_base = ou=people,dc=localhost,dc=localdomain' /etc/postfix/ldap-aliases.cf" + assert_success + run docker exec mail_with_ldap /bin/sh -c "grep 'bind_dn = cn=admin,dc=localhost,dc=localdomain' /etc/postfix/ldap-aliases.cf" + assert_success +} + # dovecot @test "checking dovecot: ldap imap connection and authentication works" { run docker exec mail_with_ldap /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-ldap-auth.txt" @@ -985,6 +1017,7 @@ load 'test_helper/bats-assert/load' assert_success } + # # RIMAP #