mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
* Add unit tests for #443 (rimap auth) * Fix #443 - configure rimap for saslauth * Fix #443 - reuse smtp-auth-login.txt when testing rimap auth
This commit is contained in:
parent
fd8ad784d1
commit
9095ba3803
12
Makefile
12
Makefile
|
@ -99,6 +99,15 @@ run:
|
||||||
-e POSTMASTER_ADDRESS=postmaster@localhost.localdomain \
|
-e POSTMASTER_ADDRESS=postmaster@localhost.localdomain \
|
||||||
--link ldap_for_mail:ldap \
|
--link ldap_for_mail:ldap \
|
||||||
-h mail.my-domain.com -t $(NAME)
|
-h mail.my-domain.com -t $(NAME)
|
||||||
|
sleep 15
|
||||||
|
docker run -d --name mail_with_imap \
|
||||||
|
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||||
|
-v "`pwd`/test":/tmp/docker-mailserver-test \
|
||||||
|
-e ENABLE_SASLAUTHD=1 \
|
||||||
|
-e SASLAUTHD_MECHANISMS=rimap \
|
||||||
|
-e SASLAUTHD_MECH_OPTIONS=127.0.0.1 \
|
||||||
|
-e POSTMASTER_ADDRESS=postmaster@localhost.localdomain \
|
||||||
|
-h mail.my-domain.com -t $(NAME)
|
||||||
# Wait for containers to fully start
|
# Wait for containers to fully start
|
||||||
sleep 15
|
sleep 15
|
||||||
|
|
||||||
|
@ -140,7 +149,8 @@ clean:
|
||||||
mail_disabled_clamav_spamassassin \
|
mail_disabled_clamav_spamassassin \
|
||||||
mail_manual_ssl \
|
mail_manual_ssl \
|
||||||
ldap_for_mail \
|
ldap_for_mail \
|
||||||
mail_with_ldap
|
mail_with_ldap \
|
||||||
|
mail_with_imap
|
||||||
|
|
||||||
@if [ -f config/postfix-accounts.cf.bak ]; then\
|
@if [ -f config/postfix-accounts.cf.bak ]; then\
|
||||||
rm -f config/postfix-accounts.cf ;\
|
rm -f config/postfix-accounts.cf ;\
|
||||||
|
|
|
@ -73,6 +73,7 @@ function register_functions() {
|
||||||
|
|
||||||
if [ "$ENABLE_SASLAUTHD" = 1 ];then
|
if [ "$ENABLE_SASLAUTHD" = 1 ];then
|
||||||
_register_setup_function "_setup_saslauthd"
|
_register_setup_function "_setup_saslauthd"
|
||||||
|
_register_setup_function "_setup_postfix_sasl"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_register_setup_function "_setup_dkim"
|
_register_setup_function "_setup_dkim"
|
||||||
|
@ -451,11 +452,15 @@ function _setup_ldap() {
|
||||||
postconf -e "virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf, ldap:/etc/postfix/ldap-groups.cf" || \
|
postconf -e "virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf, ldap:/etc/postfix/ldap-groups.cf" || \
|
||||||
notify 'inf' "==> Warning: /etc/postfix/ldap-aliases.cf or /etc/postfix/ldap-groups.cf not found"
|
notify 'inf' "==> Warning: /etc/postfix/ldap-aliases.cf or /etc/postfix/ldap-groups.cf not found"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function _setup_postfix_sasl() {
|
||||||
[ ! -f /etc/postfix/sasl/smtpd.conf ] && cat > /etc/postfix/sasl/smtpd.conf << EOF
|
[ ! -f /etc/postfix/sasl/smtpd.conf ] && cat > /etc/postfix/sasl/smtpd.conf << EOF
|
||||||
pwcheck_method: saslauthd
|
pwcheck_method: saslauthd
|
||||||
mech_list: plain login
|
mech_list: plain login
|
||||||
EOF
|
EOF
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setup_saslauthd() {
|
function _setup_saslauthd() {
|
||||||
|
@ -464,7 +469,7 @@ function _setup_saslauthd() {
|
||||||
notify 'inf' "Configuring Cyrus SASL"
|
notify 'inf' "Configuring Cyrus SASL"
|
||||||
# checking env vars and setting defaults
|
# checking env vars and setting defaults
|
||||||
[ -z $SASLAUTHD_MECHANISMS ] && SASLAUTHD_MECHANISMS=pam
|
[ -z $SASLAUTHD_MECHANISMS ] && SASLAUTHD_MECHANISMS=pam
|
||||||
[ -z $SASLAUTHD_LDAP_SEARCH_BASE ] && SASLAUTHD_MECHANISMS=pam
|
[ "$SASLAUTHD_MECHANISMS" = ldap -a -z $SASLAUTHD_LDAP_SEARCH_BASE ] && SASLAUTHD_MECHANISMS=pam
|
||||||
[ -z $SASLAUTHD_LDAP_SERVER ] && SASLAUTHD_LDAP_SERVER=localhost
|
[ -z $SASLAUTHD_LDAP_SERVER ] && SASLAUTHD_LDAP_SERVER=localhost
|
||||||
[ -z $SASLAUTHD_LDAP_FILTER ] && SASLAUTHD_LDAP_FILTER='(&(uniqueIdentifier=%u)(mailEnabled=TRUE))'
|
[ -z $SASLAUTHD_LDAP_FILTER ] && SASLAUTHD_LDAP_FILTER='(&(uniqueIdentifier=%u)(mailEnabled=TRUE))'
|
||||||
([ -z $SASLAUTHD_LDAP_SSL ] || [ $SASLAUTHD_LDAP_SSL == 0 ]) && SASLAUTHD_LDAP_PROTO='ldap://' || SASLAUTHD_LDAP_PROTO='ldaps://'
|
([ -z $SASLAUTHD_LDAP_SSL ] || [ $SASLAUTHD_LDAP_SSL == 0 ]) && SASLAUTHD_LDAP_PROTO='ldap://' || SASLAUTHD_LDAP_PROTO='ldaps://'
|
||||||
|
@ -496,6 +501,13 @@ EOF
|
||||||
-e "s|^MECHANISMS=.*|MECHANISMS="\"$SASLAUTHD_MECHANISMS\""|g" \
|
-e "s|^MECHANISMS=.*|MECHANISMS="\"$SASLAUTHD_MECHANISMS\""|g" \
|
||||||
-e "s|^MECH_OPTIONS=.*|MECH_OPTIONS="\"$SASLAUTHD_MECH_OPTIONS\""|g" \
|
-e "s|^MECH_OPTIONS=.*|MECH_OPTIONS="\"$SASLAUTHD_MECH_OPTIONS\""|g" \
|
||||||
/etc/default/saslauthd
|
/etc/default/saslauthd
|
||||||
|
|
||||||
|
if [ "$SASLAUTHD_MECHANISMS" = rimap ]; then
|
||||||
|
sed -i \
|
||||||
|
-e 's|^OPTIONS="|OPTIONS="-r |g' \
|
||||||
|
/etc/default/saslauthd
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i \
|
sed -i \
|
||||||
-e "/smtpd_sasl_path =.*/d" \
|
-e "/smtpd_sasl_path =.*/d" \
|
||||||
-e "/smtpd_sasl_type =.*/d" \
|
-e "/smtpd_sasl_type =.*/d" \
|
||||||
|
|
|
@ -66,6 +66,11 @@
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "checking process: saslauthd (saslauthd server enabled)" {
|
||||||
|
run docker exec mail_with_imap /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/saslauthd'"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# imap
|
# imap
|
||||||
#
|
#
|
||||||
|
@ -881,3 +886,25 @@
|
||||||
run docker exec mail_with_ldap /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/sasl-ldap-smtp-auth.txt | grep 'Authentication successful'"
|
run docker exec mail_with_ldap /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/sasl-ldap-smtp-auth.txt | grep 'Authentication successful'"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# RIMAP
|
||||||
|
#
|
||||||
|
|
||||||
|
# dovecot
|
||||||
|
@test "checking dovecot: ldap rimap connection and authentication works" {
|
||||||
|
run docker exec mail_with_imap /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# saslauthd
|
||||||
|
@test "checking saslauthd: sasl rimap authentication works" {
|
||||||
|
run docker exec mail_with_imap bash -c "testsaslauthd -u user1@localhost.localdomain -p mypassword"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "checking saslauthd: rimap smtp authentication" {
|
||||||
|
run docker exec mail_with_imap /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt | grep 'Authentication successful'"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue