From: Nick Porter Date: Mon, 8 Feb 2021 17:58:39 +0000 (+0000) Subject: Honour *_TEST_SERVER variables to exercise module feature tests (#3911) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a57264d59544818503bdb8bc09d1ba17b27a3d24;p=thirdparty%2Ffreeradius-server.git Honour *_TEST_SERVER variables to exercise module feature tests (#3911) * Respect individual *_TEST_SERVER variables if set * Handle module tests in subdirectories * Correct list references in SMTP tests * Use correct group for Dovecot userdb * Correct imap_setup script in light of linter comments * Extend time for exim attachment delivery * Parameterise IMAP test server settings. * Parameterise SMTP test server settings. --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a716864312..4c502b3440b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,10 @@ env: M_PERTURB: "0x42" PANIC_ACTION: "gdb -batch -x raddb/panic.gdb %e %p 1>&0 2>&0" SMTP_TEST_SERVER: 127.0.0.1 + SMTP_TEST_SERVER_PORT: 2525 IMAP_TEST_SERVER: 127.0.0.1 + IMAP_TEST_SERVER_PORT: 1430 + IMAP_TEST_SERVER_SSL_PORT: 1431 SQL_MYSQL_TEST_SERVER: 127.0.0.1 SQL_POSTGRESQL_TEST_SERVER: 127.0.0.1 LDAP_TEST_SERVER: 127.0.0.1 diff --git a/scripts/ci/imap-setup.sh b/scripts/ci/imap-setup.sh index 82ef867cd5e..ff57385f2de 100755 --- a/scripts/ci/imap-setup.sh +++ b/scripts/ci/imap-setup.sh @@ -53,6 +53,9 @@ touch "${PASSPATH}" touch "${LOGPATH}" touch "${LOGINFOPATH}" +# Get primary group name +GROUP=$(id -gn) + # # Add users to the password file # @@ -85,7 +88,7 @@ cp "${CIDIR}/dovecot/fr_dovecot.conf" "${TLSCONF}" # Configure the specifics for the non_tls dovecot server echo " -instance_name = "fr_dovecot" +instance_name = \"fr_dovecot\" ssl = no @@ -103,7 +106,7 @@ service imap-login { # Configure the specifics for the tls dovecot server echo " -instance_name = "fr_tls_dovecot" +instance_name = \"fr_tls_dovecot\" base_dir = ${TLSRUNDIR} @@ -135,7 +138,7 @@ verbose_ssl = yes " >> "${TLSCONF}" # Make sure there is a clean imap-stop.sh file -> ${CIDIR}/imap-stop.sh +echo "" > "${CIDIR}/imap-stop.sh" # # Add system specific dovecot information @@ -170,18 +173,18 @@ default_login_user = ${USER} \ echo " userdb { driver = static - args = uid=${USER} gid=${USER} + args = uid=${USER} gid=${GROUP} } \ " >> "${CONFPATH}" # Run the imap server echo "Starting a dovecot imap server at ${CONFPATH}" -if ! dovecot -c ${CONFPATH}; then +if ! dovecot -c "${CONFPATH}"; then echo "The server failed to start up. Here is fr_dovecot.log" - cat ${LOGPATH} + cat "${LOGPATH}" echo "And here is fr_dovecot-info.log" - cat ${LOGINFOPATH} + cat "${LOGINFOPATH}" fi echo "dovecot -c ${CONFPATH} stop" >> "${CIDIR}/imap-stop.sh" diff --git a/src/tests/modules/all.mk b/src/tests/modules/all.mk index f022a0e167a..0375a3d2011 100644 --- a/src/tests/modules/all.mk +++ b/src/tests/modules/all.mk @@ -48,9 +48,10 @@ else ifdef ${1}_require_test_server ifdef TEST_SERVER - # define FOO_TEST_SERVER - $(eval $(shell echo ${1} | tr a-z A-Z)_TEST_SERVER := $(TEST_SERVER)) - else + # define and export FOO_TEST_SERVER if it's not already defined + $(eval export $(shell echo ${1} | tr a-z A-Z)_TEST_SERVER ?= $(TEST_SERVER)) + endif + ifeq "$($(shell echo ${1} | tr a-z A-Z)_TEST_SERVER)" "" # the module requires a test server, but we don't have one. Skip it. FILES_SKIP += ${2} endif @@ -70,7 +71,7 @@ $(eval $(call TEST_BOOTSTRAP)) # and make the output file depend on the library. That way if the # module is re-built, then the tests are re-run. # -$(foreach x, $(FILES), $(eval $$(OUTPUT.$(TEST))/$x: $(patsubst %,$(BUILD_DIR)/lib/rlm_%.la,$(patsubst %/,%,$(dir $x))))) +$(foreach x, $(FILES), $(eval $$(OUTPUT.$(TEST))/$x: $(patsubst %,$(BUILD_DIR)/lib/rlm_%.la,$(patsubst %/,%,$(firstword $(subst /, ,$(dir $x))))))) # diff --git a/src/tests/modules/imap/imap_bad_tls/module.conf b/src/tests/modules/imap/imap_bad_tls/module.conf index 23a4f74b744..726a6bd6aa3 100644 --- a/src/tests/modules/imap/imap_bad_tls/module.conf +++ b/src/tests/modules/imap/imap_bad_tls/module.conf @@ -1,7 +1,7 @@ #IMAP unit test config imap imap_bad_tls { - uri = "127.0.0.1:1431" + uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}" timeout = 1000 tls { diff --git a/src/tests/modules/imap/imap_opt_tls/module.conf b/src/tests/modules/imap/imap_opt_tls/module.conf index f5ea097f0fb..5f9d7dece32 100644 --- a/src/tests/modules/imap/imap_opt_tls/module.conf +++ b/src/tests/modules/imap/imap_opt_tls/module.conf @@ -1,7 +1,7 @@ #IMAP unit test config imap imap_try_tls { - uri = "127.0.0.1:1431" + uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}" timeout = 1s tls { diff --git a/src/tests/modules/imap/imap_tls/module.conf b/src/tests/modules/imap/imap_tls/module.conf index 3a3dd35b395..e6f82f288cd 100644 --- a/src/tests/modules/imap/imap_tls/module.conf +++ b/src/tests/modules/imap/imap_tls/module.conf @@ -1,7 +1,7 @@ #IMAP unit test config imap imap_tls { - uri = "127.0.0.1:1431" + uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}" timeout = 1s tls { diff --git a/src/tests/modules/imap/module.conf b/src/tests/modules/imap/module.conf index 51547b05606..990db988917 100644 --- a/src/tests/modules/imap/module.conf +++ b/src/tests/modules/imap/module.conf @@ -1,5 +1,5 @@ #IMAP unit test config imap { - uri = "127.0.0.1:1430" + uri = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_PORT}" timeout = 1s } diff --git a/src/tests/modules/smtp/smtp_attachment/module.conf b/src/tests/modules/smtp/smtp_attachment/module.conf index 627655076ed..284a4d52262 100644 --- a/src/tests/modules/smtp/smtp_attachment/module.conf +++ b/src/tests/modules/smtp/smtp_attachment/module.conf @@ -24,7 +24,7 @@ smtp { message_id = "123456789@example.com" } - uri = "127.0.0.1:2525" + uri = "$ENV{SMTP_TEST_SERVER}:$ENV{SMTP_TEST_SERVER_PORT}" timeout = 5s template_directory = "$ENV{top_srcdir}build/ci/exim4" diff --git a/src/tests/modules/smtp/smtp_attachment/tls_attachment.unlang b/src/tests/modules/smtp/smtp_attachment/tls_attachment.unlang index e97d72985f0..d1e52073f58 100644 --- a/src/tests/modules/smtp/smtp_attachment/tls_attachment.unlang +++ b/src/tests/modules/smtp/smtp_attachment/tls_attachment.unlang @@ -17,13 +17,13 @@ update request { smtp.authorize # -# Wait up to a tenth second for exim to deliver the email +# Wait up to half a second for exim to deliver the email # Then confirm it was delivered # if (`/bin/sh -c "for i in 1 2 3 4 5 ; \ do if [ -e build/ci/exim4/mail/smtp_attachment_receiver ] ;\ then break; \ -fi; sleep .02;\ +fi; sleep .1;\ done ; \ test -f build/ci/exim4/mail/smtp_attachment_receiver ;\ echo $?"` == "1") { diff --git a/src/tests/modules/smtp/smtp_authenticate/tls_authenticate.unlang b/src/tests/modules/smtp/smtp_authenticate/tls_authenticate.unlang index 176db9e07cc..505de6f4741 100644 --- a/src/tests/modules/smtp/smtp_authenticate/tls_authenticate.unlang +++ b/src/tests/modules/smtp/smtp_authenticate/tls_authenticate.unlang @@ -18,7 +18,7 @@ else { reject } -if (&request:TLS-Cert-Issuer =~ /@example\.org/) { +if (&request.TLS-Cert-Issuer =~ /@example\.org/) { test_pass } else { test_fail diff --git a/src/tests/modules/smtp/smtp_crln/tls_crln.unlang b/src/tests/modules/smtp/smtp_crln/tls_crln.unlang index 9fee5e0381b..d84711e3769 100644 --- a/src/tests/modules/smtp/smtp_crln/tls_crln.unlang +++ b/src/tests/modules/smtp/smtp_crln/tls_crln.unlang @@ -36,7 +36,7 @@ else { reject } -if (&request:TLS-Cert-Issuer =~ /@example\.org/) { +if (&request.TLS-Cert-Issuer =~ /@example\.org/) { test_pass } else { test_fail diff --git a/src/tests/modules/smtp/smtp_stringparse/tls_stringparse.unlang b/src/tests/modules/smtp/smtp_stringparse/tls_stringparse.unlang index f6e7b223d55..38387eea68c 100644 --- a/src/tests/modules/smtp/smtp_stringparse/tls_stringparse.unlang +++ b/src/tests/modules/smtp/smtp_stringparse/tls_stringparse.unlang @@ -33,7 +33,7 @@ else { reject } -if (&request:TLS-Cert-Issuer =~ /@example\.org/) { +if (&request.TLS-Cert-Issuer =~ /@example\.org/) { test_pass } else { test_fail