From: Arran Cudbard-Bell Date: Mon, 20 Sep 2021 23:09:41 +0000 (-0500) Subject: Fix redis ippool tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26edb5ec8d1112c680344e6e79d6efaa5fbc0d4f;p=thirdparty%2Ffreeradius-server.git Fix redis ippool tests --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2df68a2ebd..cf3042a3f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -306,7 +306,7 @@ jobs: # SMTP_TEST_SERVER: 127.0.0.1 # SMTP_TEST_SERVER_PORT: 2525 REDIS_TEST_SERVER: 127.0.0.1 -# REDIS_IPPOOL_TEST_SERVER: 127.0.0.1 + REDIS_IPPOOL_TEST_SERVER: 127.0.0.1 # IMAP_TEST_SERVER: 127.0.0.1 # IMAP_TEST_SERVER_PORT: 1430 # IMAP_TEST_SERVER_SSL_PORT: 1431 diff --git a/src/tests/modules/redis_ippool/all.mk.broken b/src/tests/modules/redis_ippool/all.mk similarity index 77% rename from src/tests/modules/redis_ippool/all.mk.broken rename to src/tests/modules/redis_ippool/all.mk index 0662da1c86..de0fd4a107 100644 --- a/src/tests/modules/redis_ippool/all.mk.broken +++ b/src/tests/modules/redis_ippool/all.mk @@ -6,6 +6,3 @@ # Don't test redis if REDIS_TEST_SERVER ENV is not set redis_ippool_require_test_server := 1 - -redis_ippool.test: - ${Q}echo OK: redis_ippool.test diff --git a/src/tests/modules/redis_ippool/alloc.unlang b/src/tests/modules/redis_ippool/alloc.unlang index 8b3fb47d1c..cde0308a2a 100644 --- a/src/tests/modules/redis_ippool/alloc.unlang +++ b/src/tests/modules/redis_ippool/alloc.unlang @@ -37,13 +37,13 @@ update request { &Tmp-Date-0 := "%l" } -if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %(integer:%{Tmp-Date-0})}" > 20) { +if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 20) { test_pass } else { test_fail } -if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %(integer:%{Tmp-Date-0})}" < 40) { +if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 40) { test_pass } else { test_fail @@ -52,19 +52,19 @@ if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP- # # Verify the IP hash has been set # -if ("%{redis:HGET '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} 'device')" == '00:11:22:33:44:55') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') { test_pass } else { test_fail @@ -79,7 +79,7 @@ if (&reply.IP-Pool.Range == '192.168.0.0') { # # Verify the lease has been associated with the device # -if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}") { +if (&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})") { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/module.conf b/src/tests/modules/redis_ippool/module.conf index 0ce3b8c9c8..ba2819346c 100644 --- a/src/tests/modules/redis_ippool/module.conf +++ b/src/tests/modules/redis_ippool/module.conf @@ -8,7 +8,7 @@ # expansion. # redis_ippool { - device = &Calling-Station-ID + owner = &Calling-Station-ID gateway = &NAS-IP-Address pool_name = &control.IP-Pool.Name diff --git a/src/tests/modules/redis_ippool/pool_tool_delete.unlang b/src/tests/modules/redis_ippool/pool_tool_delete.unlang index 22b5974c3e..8fd75e77d0 100644 --- a/src/tests/modules/redis_ippool/pool_tool_delete.unlang +++ b/src/tests/modules/redis_ippool/pool_tool_delete.unlang @@ -42,7 +42,7 @@ update request { # # Verify the association with the device has been removed # -if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == '0') { +if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') { test_pass } else { test_fail @@ -51,14 +51,14 @@ if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" # # Verify the hash information is removed # -if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}'}" == '0') { +if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address})" == '0') { test_pass } else { test_fail } # Check the ZSCORE -if ("%{redis:ZCOUNT '{%{control.IP-Pool.Name}%}:pool' -inf +inf}" == 0) { +if ("%(redis:ZCOUNT {%{control.IP-Pool.Name}%}:pool -inf +inf)" == 0) { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/pool_tool_modify.unlang b/src/tests/modules/redis_ippool/pool_tool_modify.unlang index 3f8c23117d..daae378669 100644 --- a/src/tests/modules/redis_ippool/pool_tool_modify.unlang +++ b/src/tests/modules/redis_ippool/pool_tool_modify.unlang @@ -17,7 +17,7 @@ update request { # # Verify the range was set OK # -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:192.168.0.1 range}" == '192.168.0.0') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '192.168.0.0') { test_pass } else { test_fail @@ -33,7 +33,7 @@ update request { # # Check it was updated # -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:192.168.0.1 range}" == '10.0.0.0') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '10.0.0.0') { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/pool_tool_release.unlang b/src/tests/modules/redis_ippool/pool_tool_release.unlang index 556027b8fe..cb10f242b7 100644 --- a/src/tests/modules/redis_ippool/pool_tool_release.unlang +++ b/src/tests/modules/redis_ippool/pool_tool_release.unlang @@ -42,7 +42,7 @@ update request { # # Verify the association with the device has been removed # -if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == '0') { +if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') { test_pass } else { test_fail @@ -51,26 +51,26 @@ if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" # # Verify the hash information is retained # -if ("%{redis:HGET '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} device)" == '00:11:22:33:44:55') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') { test_pass } else { test_fail } # Check the ZSCORE -if ("%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'}" == 0) { +if ("%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address})" == 0) { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/release.unlang b/src/tests/modules/redis_ippool/release.unlang index 5d02dc10d5..6e0b3e1ff7 100644 --- a/src/tests/modules/redis_ippool/release.unlang +++ b/src/tests/modules/redis_ippool/release.unlang @@ -51,7 +51,7 @@ if (updated) { # # Verify the association with the device has been removed # -if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == '0') { +if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') { test_pass } else { test_fail @@ -60,19 +60,19 @@ if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" # # Verify the hash information is retained # -if ("%{redis:HGET '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} device)" == '00:11:22:33:44:55') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') { test_pass } else { test_fail @@ -83,13 +83,13 @@ update request { &Tmp-Date-0 := "%l" } -if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %(integer:%{Tmp-Date-0})}" > 0) { +if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 0) { test_pass } else { test_fail } -if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %(integer:%{Tmp-Date-0})}" < 10) { +if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 10) { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/update.unlang b/src/tests/modules/redis_ippool/update.unlang index d5bf6d9bc7..acff7616d0 100644 --- a/src/tests/modules/redis_ippool/update.unlang +++ b/src/tests/modules/redis_ippool/update.unlang @@ -37,7 +37,7 @@ if (&reply.Session-Timeout == 30) { } # 4. Verify the gateway was set -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') { test_pass } else { test_fail @@ -73,35 +73,35 @@ update request { &Tmp-Date-0 := "%l" } -if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %(integer:%{Tmp-Date-0})}" > 50) { +if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 50) { test_pass } else { test_fail } # 9. -if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %(integer:%{Tmp-Date-0})}" < 70) { +if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 70) { test_pass } else { test_fail } # 10. Verify the lease is still associated with the device -if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}") { +if (&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})") { test_pass } else { test_fail } # 11. And that the device object will expire a suitable number of seconds into the future -if ("%{redis:TTL '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == 60) { +if ("%(redis:TTL {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == 60) { test_pass } else { test_fail } # 12. Verify the gateway was updated -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{request.Framed-IP-Address} gateway}" == '127.0.0.2') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{request.Framed-IP-Address} gateway)" == '127.0.0.2') { test_pass } else { test_fail @@ -145,7 +145,7 @@ if (invalid) { } # 16. Verify the lease is still associated with the previous device -if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.IP-Pool.Name}%}:device:00:11:22:33:44:55'}") { +if (&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:00:11:22:33:44:55)") { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/update_alloc.unlang b/src/tests/modules/redis_ippool/update_alloc.unlang index 90ba2040c7..f069c4fb5b 100644 --- a/src/tests/modules/redis_ippool/update_alloc.unlang +++ b/src/tests/modules/redis_ippool/update_alloc.unlang @@ -40,7 +40,7 @@ if (&reply.Session-Timeout == 60) { } # 4. Verify the gateway was set -if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') { test_pass } else { test_fail