]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix redis ippool tests
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 20 Sep 2021 23:09:41 +0000 (18:09 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 20 Sep 2021 23:10:07 +0000 (18:10 -0500)
.github/workflows/ci.yml
src/tests/modules/redis_ippool/all.mk [moved from src/tests/modules/redis_ippool/all.mk.broken with 77% similarity]
src/tests/modules/redis_ippool/alloc.unlang
src/tests/modules/redis_ippool/module.conf
src/tests/modules/redis_ippool/pool_tool_delete.unlang
src/tests/modules/redis_ippool/pool_tool_modify.unlang
src/tests/modules/redis_ippool/pool_tool_release.unlang
src/tests/modules/redis_ippool/release.unlang
src/tests/modules/redis_ippool/update.unlang
src/tests/modules/redis_ippool/update_alloc.unlang

index 2df68a2ebdc5db2c39bd67c4be93713a5b6fed9f..cf3042a3f0b113da3fc0b287fd4d1f2319d08138 100644 (file)
@@ -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
similarity index 77%
rename from src/tests/modules/redis_ippool/all.mk.broken
rename to src/tests/modules/redis_ippool/all.mk
index 0662da1c861e7148339309a117a09886a9e31884..de0fd4a1070227302d4d876717acde2038b00486 100644 (file)
@@ -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
index 8b3fb47d1c90d42ab83ee83747f77f9808f8d073..cde0308a2a1c59ea0fcd646bf8b48ef6fb862152 100644 (file)
@@ -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
index 0ce3b8c9c8992ed14471fe91fbc90797cc1cd508..ba2819346c851d0d635d58759119561ac765b07f 100644 (file)
@@ -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
 
index 22b5974c3e62348409fcf15b57e311abfd579801..8fd75e77d078f73bee63794543b43c9b0114a85e 100644 (file)
@@ -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
index 3f8c23117d94056a112ff593b0831916b0202bd2..daae378669948ae8939fd299ef869e0276198e12 100644 (file)
@@ -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
index 556027b8fe167d35e9522f11335c7688317ecd0e..cb10f242b7a08945fbccd96c5ba8d1d42dbf2e3f 100644 (file)
@@ -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
index 5d02dc10d5f848083e344a3ab15a77be0af12087..6e0b3e1ff70456cc69b5e25a86207888b31587fa 100644 (file)
@@ -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
index d5bf6d9bc7c45d0df24e793593ebefd72de90ed7..acff7616d058bc6071c3e7332a8fcee9b4a8b5e7 100644 (file)
@@ -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
index 90ba2040c7c645e0d2f98ce7cde10b73d076e8ce..f069c4fb5b8031dc0811e9f75e640925751c3a68 100644 (file)
@@ -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