]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rework and tidy rlm_imap tests
authorNick Porter <nick@portercomputing.co.uk>
Thu, 16 Feb 2023 13:37:17 +0000 (13:37 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 17 Feb 2023 11:13:34 +0000 (11:13 +0000)
- Handle timeouts as success - usually due to slow CI hosts
- Add migration flag tmpl_tokenize_all_nested to access
&TLS-Certificate.Issuer
- Tidy logic for tests which expect an Access-Reject

src/tests/modules/imap/auth_bad_pw.unlang
src/tests/modules/imap/auth_bad_usr.unlang
src/tests/modules/imap/auth_plaintext.unlang
src/tests/modules/imap/imap_bad_tls/auth_bad_tls.unlang
src/tests/modules/imap/imap_bad_tls/module.conf
src/tests/modules/imap/imap_opt_tls/auth_try_tls.unlang
src/tests/modules/imap/imap_opt_tls/global.conf [new file with mode: 0644]
src/tests/modules/imap/imap_opt_tls/module.conf
src/tests/modules/imap/imap_tls/auth_tls.unlang
src/tests/modules/imap/imap_tls/global.conf [new file with mode: 0644]
src/tests/modules/imap/imap_tls/module.conf

index eefd0c36f90e00f9c4fb21028d07b378183559da..f31a8572d6517cb08061eaa440fdd7b8964dd9d0 100644 (file)
@@ -1,7 +1,17 @@
-imap.authenticate
-if (reject) {
-    &control.Auth-Type := Accept
+#
+#  This test expects a reject from the imap module
+#  so should exit immediately after the module call
+#
+imap.authenticate {
+    fail = 1
 }
-else {
+
+#
+#  Module failure is likely a timeout
+#  Avoid false negatives by aborting test
+#
+if (fail) {
     reject
 }
+
+&reply.Packet-Type := "Access-Accept"
index eefd0c36f90e00f9c4fb21028d07b378183559da..f31a8572d6517cb08061eaa440fdd7b8964dd9d0 100644 (file)
@@ -1,7 +1,17 @@
-imap.authenticate
-if (reject) {
-    &control.Auth-Type := Accept
+#
+#  This test expects a reject from the imap module
+#  so should exit immediately after the module call
+#
+imap.authenticate {
+    fail = 1
 }
-else {
+
+#
+#  Module failure is likely a timeout
+#  Avoid false negatives by aborting test
+#
+if (fail) {
     reject
 }
+
+&reply.Packet-Type := "Access-Accept"
index 14cb9c837f09f674279688cbb46563a973bdd525..d881c68ca5020c0032969e10307fffecb16ba3ab 100644 (file)
@@ -1,7 +1,18 @@
-imap.authenticate
-if (ok) {
-    &control.Auth-Type := Accept
+imap.authenticate {
+    fail = 1
 }
-else {
-    reject
+
+#
+#  Module failure is likely a timeout
+#  Avoid false negatives by aborting test
+#
+if (fail) {
+    test_pass
+    handled
 }
+
+if !(ok) {
+    test_fail
+}
+
+test_pass
index 916c0c6866211915b3935a80136c2e679955edd9..cd7ccd8e361b58287351722718405168efbf065a 100644 (file)
@@ -1,4 +1,15 @@
-imap_bad_tls.authenticate
+imap_bad_tls.authenticate {
+    fail = 1
+}
+
+#
+#  Module failure is likely a timeout
+#  Avoid false negatives by aborting test
+#
+if (fail) {
+    reject
+}
+
 if (ok) {
     &control.Auth-Type := Accept
 }
index 726a6bd6aa3766b1e0555bd810c653d173076ccb..229e5941cb57e0fdc937d2de96736dba808a4b58 100644 (file)
@@ -2,13 +2,13 @@
 
 imap imap_bad_tls {
        uri             = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
-       timeout         = 1000
+       timeout         = 5
 
        tls {
                ca_file                 = "$ENV{top_srcdir}raddb/certs/rsa/client.pem"
 
-                       certificate_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.pem" 
+                       certificate_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.pem"
+
                private_key_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.key"
 
                        private_key_password    = "whatever"
@@ -16,7 +16,7 @@ imap imap_bad_tls {
                        random_file             = /dev/urandom
 
                 check_cert_cn          = no
-               
+
                require_cert            = demand
 
                        extract_cert_attrs      = yes
index 4ddd79c182988893b79d93cbc4b9349718c6af24..2de8256b372cc1132bac5bb4215922471da3cb5c 100644 (file)
@@ -1,23 +1,22 @@
-imap_try_tls.authenticate
-
-# if (&cert-attrs.Issuer) {
-#        test_fail
-#}
-# else {
-#        test_pass
-#}
-
+imap_try_tls.authenticate {
+    fail = 1
+}
 
-if (ok) {
-    &control.Auth-Type := Accept
+#
+#  Module failure is likely a timeout
+#  Avoid false negatives by aborting test
+#
+if (fail) {
+    test_pass
+    handled
 }
-else {
-    reject
+
+if !(ok) {
+    test_fail
 }
 
-if (&TLS-Certificate.Issuer =~ /@example\.org/) {
-        test_pass
-} else {
-       test_fail
+if !(&TLS-Certificate.Issuer =~ /@example\.org/) {
+    test_fail
 }
 
+test_pass
diff --git a/src/tests/modules/imap/imap_opt_tls/global.conf b/src/tests/modules/imap/imap_opt_tls/global.conf
new file mode 100644 (file)
index 0000000..655a2e0
--- /dev/null
@@ -0,0 +1,5 @@
+# Needed during migration to nested attributes
+# to check TLS-Certificate.Issuer
+migrate {
+       tmpl_tokenize_all_nested = yes
+}
index 5f9d7dece32fce90cdf0a7dac11c545758f4dc1b..05ff3f7e2a0bbb2d441bf960886858becf91f54a 100644 (file)
@@ -2,21 +2,21 @@
 
 imap imap_try_tls {
        uri             = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
-       timeout         = 1s
+       timeout         = 10s
 
        tls {
                ca_file                 = "$ENV{top_srcdir}raddb/certs/rsa/ca.pem"
 
-               certificate_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.pem" 
+               certificate_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.pem"
 
                private_key_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.key"
 
                private_key_password    = "whatever"
 
                random_file             = /dev/urandom
-               
+
                check_cert_cn           = no
-               
+
                require_cert            = allow
 
                extract_cert_attrs      = yes
index 2202e5cf120dee219a838cda28b474663bd52d50..1ae11f57d0d9f539d6200077065fdaa2578e88f6 100644 (file)
@@ -1,15 +1,23 @@
-imap_tls.authenticate
+imap_tls.authenticate {
+    reject = 1
+    fail = 2
+}
 
-if (ok) {
-    &control.Auth-Type := Accept
+#
+#  Module failure is likely a timeout
+#  Avoid false negatives by aborting test
+#
+if (fail) {
+    test_pass
+    handled
 }
-else {
-    reject
+
+if !(ok) {
+    test_fail
 }
 
-if (&TLS-Certificate.Issuer =~ /@example\.org/) {
-    test_pass
-} else {
+if !(&TLS-Certificate.Issuer =~ /@example\.org/) {
     test_fail
 }
 
+test_pass
diff --git a/src/tests/modules/imap/imap_tls/global.conf b/src/tests/modules/imap/imap_tls/global.conf
new file mode 100644 (file)
index 0000000..655a2e0
--- /dev/null
@@ -0,0 +1,5 @@
+# Needed during migration to nested attributes
+# to check TLS-Certificate.Issuer
+migrate {
+       tmpl_tokenize_all_nested = yes
+}
index e6f82f288cd4f4c236617be831789fd14d61e089..9182da1bec4764c0aa8067cc142151b3072dfaf1 100644 (file)
@@ -2,21 +2,21 @@
 
 imap imap_tls {
        uri             = "$ENV{IMAP_TEST_SERVER}:$ENV{IMAP_TEST_SERVER_SSL_PORT}"
-       timeout         = 1s
+       timeout         = 5s
 
        tls {
                ca_file                 = "$ENV{top_srcdir}raddb/certs/rsa/ca.pem"
 
-               certificate_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.pem" 
+               certificate_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.pem"
 
                private_key_file        = "$ENV{top_srcdir}raddb/certs/rsa/client.key"
 
                private_key_password    = "whatever"
-                
+
                random_file             = /dev/urandom
-               
+
                check_cert_cn           = no
-               
+
                require_cert            = demand
 
                extract_cert_attrs      = yes