]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Honour *_TEST_SERVER variables to exercise module feature tests (#3911)
authorNick Porter <nick@portercomputing.co.uk>
Mon, 8 Feb 2021 17:58:39 +0000 (17:58 +0000)
committerGitHub <noreply@github.com>
Mon, 8 Feb 2021 17:58:39 +0000 (17:58 +0000)
* 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.

12 files changed:
.github/workflows/ci.yml
scripts/ci/imap-setup.sh
src/tests/modules/all.mk
src/tests/modules/imap/imap_bad_tls/module.conf
src/tests/modules/imap/imap_opt_tls/module.conf
src/tests/modules/imap/imap_tls/module.conf
src/tests/modules/imap/module.conf
src/tests/modules/smtp/smtp_attachment/module.conf
src/tests/modules/smtp/smtp_attachment/tls_attachment.unlang
src/tests/modules/smtp/smtp_authenticate/tls_authenticate.unlang
src/tests/modules/smtp/smtp_crln/tls_crln.unlang
src/tests/modules/smtp/smtp_stringparse/tls_stringparse.unlang

index 1a7168643122ec07b3e6811202ef54e07fc85e82..4c502b3440bc00075e55747925a2b5ea5c088313 100644 (file)
@@ -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
index 82ef867cd5efa0e16e727170c66811660b4f2bae..ff57385f2de2098da31c2c24772cef40eb8c4413 100755 (executable)
@@ -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"
index f022a0e167a629962c4cda253a94edcf3a4a9aa6..0375a3d201105ae42218c66ff091ab37ece16553 100644 (file)
@@ -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)))))))
 
 
 #
index 23a4f74b74493a5f6e79564c8a9f2aded11e0275..726a6bd6aa3766b1e0555bd810c653d173076ccb 100644 (file)
@@ -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 {
index f5ea097f0fbbd826d459285789c56188c8cb9229..5f9d7dece32fce90cdf0a7dac11c545758f4dc1b 100644 (file)
@@ -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 {
index 3a3dd35b3953412ddb2eb473c2d04e44fe5892d5..e6f82f288cd4f4c236617be831789fd14d61e089 100644 (file)
@@ -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 {
index 51547b05606a14cae5b9ac0e5abc610c1c8aaf16..990db9889175a64e1d33d6f12fa98628f2056a28 100644 (file)
@@ -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
 }
index 627655076ed49090e64ee0dbc99a2e45d4f02211..284a4d52262e091664509f27bead453925cf7823 100644 (file)
@@ -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"
 
index e97d72985f01695020c396374ac8aec324e5aa1c..d1e52073f582efd35ac830b0d1d32c6e2ec4af66 100644 (file)
@@ -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") {
index 176db9e07cc256c708b7490b6e54da2f7cdb5e00..505de6f474128a31fbdf38b737948d4857a79eb2 100644 (file)
@@ -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
index 9fee5e0381b98ac9658bb483b122a4cac71523ae..d84711e3769e59cfc8b7be7c2955f5d59c8bb58e 100644 (file)
@@ -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
index f6e7b223d55955a1af5a4d6fdfd7edbd97434b3f..38387eea68ca32eee1f384b03405726a6d852a9b 100644 (file)
@@ -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