default: 1430
imap_test_server_ssl_port:
description: IMAP server IMAPS port
- default: 1431
+ default: 1432
use_docker:
desription: True if running in a Docker container
rest_test_ssl_port: 8443
imap_test_server: 127.0.0.1
imap_test_server_port: 1430
- imap_test_server_ssl_port: 1431
+ imap_test_server_ssl_port: 1432
- name: Run fuzzer
uses: ./.github/actions/fuzzer
-#!/bin/sh -e
+#!/bin/bash
#
# ### This is a script to setup a dovecot imap server for testing rlm_imap
# Used for creating `imap-stop.sh`
CIDIR="${BASEDIR}/scripts/ci"
-# When running on Docker, USER is not set
-USER=${USER:-root}
-
#
# Create all the necessary files
#
#
# Add users to the password file
#
-
-# Generate passwords for the users
-USER1P=$(doveadm -o stats_writer_socket_path= pw -p test1 -s CRYPT)
-USER2P=$(doveadm -o stats_writer_socket_path= pw -p test2 -s CRYPT)
-USER3P=$(doveadm -o stats_writer_socket_path= pw -p test3 -s CRYPT)
-
-# Add user password combinations
-echo "\
-user1:${USER1P}::::::
-" >"${PASSPATH}"
-
-echo "\
-user2:${USER2P}::::::
-" >>"${PASSPATH}"
-
-echo "\
-user3:${USER3P}::::::
-" >>"${PASSPATH}"
+rm -f ${PASSPATH}
+for i in {1..3}; do
+ PASS=$(doveadm -o stats_writer_socket_path= pw -p test${i} -s CRYPT)
+ echo "user${i}:${PASS}::::::
+" >> "${PASSPATH}"
+done
#
# Configure instance specific dovecot information
# Module failure is likely a timeout
# Avoid false negatives by aborting test
#
-if (fail) {
- test_pass
- handled
+if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
+ test_fail
+}
+
+#
+# Check for module failing with missing attributes
+#
+&request -= &User-Password[*]
+
+imap.authenticate {
+ fail = 1
+ invalid = 2
+}
+
+if !(invalid) {
+ test_fail
+}
+
+&User-Password := 'test2'
+&request -= &User-Name[*]
+
+imap.authenticate {
+ fail = 1
+ invalid = 2
+}
+
+if !(invalid) {
+ test_fail
+}
+
+#
+# Now do multiple authentications of different users
+#
+
+&User-Name := 'user2'
+imap.authenticate {
+ fail = 1
+}
+
+if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
+ test_fail
+}
+
+&User-Name := 'user3'
+&User-Password := 'test3'
+imap.authenticate {
+ fail = 1
+}
+
+if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
+ test_fail
+}
+
+#
+# And repeat all three
+#
+&User-Name := 'user1'
+&User-Password := 'test1'
+imap.authenticate {
+ fail = 1
+}
+
+if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
+ test_fail
+}
+
+&User-Name := 'user2'
+&User-Password := 'test2'
+imap.authenticate {
+ fail = 1
+}
+
+if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
+ test_fail
+}
+
+&User-Name := 'user3'
+&User-Password := 'test3'
+imap.authenticate {
+ fail = 1
}
if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
test_fail
}
#IMAP unit test config
imap imap_bad_tls {
- uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
+ uri = "imaps://$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
timeout = 5
tls {
#IMAP unit test config
imap imap_try_tls {
- uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
+ uri = "imaps://$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
timeout = 10s
tls {
# Module failure is likely a timeout
# Avoid false negatives by aborting test
#
-if (fail) {
- test_pass
- handled
-}
-
if !(ok) {
+ if (&Module-Failure-Message[*] == "imap: curl request failed: Timeout was reached (28)") {
+ test_pass
+ handled
+ }
test_fail
}
#IMAP unit test config
imap imap_tls {
- uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
+ uri = "imaps://$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
timeout = 5s
tls {