]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Tidy other redis_ippool tests
authorNick Porter <nick@portercomputing.co.uk>
Thu, 25 May 2023 14:32:25 +0000 (15:32 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 8 Jun 2023 14:13:48 +0000 (10:13 -0400)
src/tests/modules/redis_ippool/alloc.unlang
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/update.unlang
src/tests/modules/redis_ippool/update_alloc.unlang

index b56ccbb53de879226a86f5017587ae8b228a2aee..9b48c3cd27250b12bd543517dfb5caa06173f818 100644 (file)
@@ -14,15 +14,11 @@ $INCLUDE cluster_reset.inc
 #  Check allocation
 #
 redis_ippool
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
-if (&reply.Framed-IP-Address == 192.168.0.1) {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == 192.168.0.1) {
        test_fail
 }
 
@@ -31,60 +27,44 @@ if (&reply.Framed-IP-Address == 192.168.0.1) {
 #
 &Tmp-Date-0 := "%l"
 
-if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 20) {
-       test_pass
-} else {
+if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 20) {
        test_fail
 }
 
-if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 40) {
-       test_pass
-} else {
+if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 40) {
        test_fail
 }
 
 #
 #  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') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} 'device')" == '00:11:22:33:44:55') {
        test_fail
 }
 
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
        test_fail
 }
 
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') {
        test_fail
 }
 
-if (&reply.IP-Pool.Range == '192.168.0.0') {
-       test_pass
-} else {
+if !(&reply.IP-Pool.Range == '192.168.0.0') {
        test_fail
 }
 
 #
 #  Verify the lease has been associated with the device
 #
-if (&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})") {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})") {
        test_fail
 }
 
 #
 #  Check we got the correct lease time back
 #
-if (&reply.Session-Timeout == 30) {
-       test_pass
-} else {
+if !(&reply.Session-Timeout == 30) {
        test_fail
 }
 
@@ -102,27 +82,21 @@ if (&reply.Session-Timeout == 30) {
 #  Check we get the same lease, with the same lease time
 #
 redis_ippool
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
 #
 #  Check the ranges are the same
 #
-if (&IP-Pool.Range == &reply.IP-Pool.Range) {
-       test_pass
-} else {
+if !(&IP-Pool.Range == &reply.IP-Pool.Range) {
        test_fail
 }
 
 #
 #  Check the IP addresses are the same
 #
-if (&Framed-IP-Address == &reply.Framed-IP-Address) {
-       test_pass
-} else {
+if !(&Framed-IP-Address == &reply.Framed-IP-Address) {
        test_fail
 }
 
@@ -132,9 +106,7 @@ if (&Framed-IP-Address == &reply.Framed-IP-Address) {
 #  The fudge factor is to allow for delays running ippool tool and script interpretation
 #  as we should be allocating the same lesase as before, but its TTL could be slightly lower.
 #
-if ("%{expr:&Session-Timeout - &reply.Session-Timeout}" < 5) {
-       test_pass
-} else {
+if ("%{expr:&Session-Timeout - &reply.Session-Timeout}" > 5) {
        test_fail
 }
 
@@ -146,19 +118,17 @@ if ("%{expr:&Session-Timeout - &reply.Session-Timeout}" < 5) {
 &Calling-Station-ID := 'another_mac'
 
 redis_ippool
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
 #
 #  Check we got the right lease
 #
-if (&reply.Framed-IP-Address == 192.168.1.1) {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == 192.168.1.1) {
        test_fail
 }
 
 &reply := {}
+
+test_pass
index c2f5840ae3bcd2aa4b3950a5ceca2dc360e55086..ebc65fd63519f6e88675c466e063b6114434cfaf 100644 (file)
@@ -16,15 +16,11 @@ $INCLUDE cluster_reset.inc
 redis_ippool {
        invalid = 1
 }
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
-if (&reply.Framed-IP-Address == 192.168.0.1) {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == 192.168.0.1) {
        test_fail
 }
 
@@ -36,26 +32,22 @@ if (&reply.Framed-IP-Address == 192.168.0.1) {
 #
 #  Verify the association with the device has been removed
 #
-if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') {
-       test_pass
-} else {
+if !("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') {
        test_fail
 }
 
 #
 #  Verify the hash information is removed
 #
-if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address})" == '0') {
-       test_pass
-} else {
+if !("%(redis:EXISTS {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address})" == '0') {
        test_fail
 }
 
 # Check the ZSCORE
-if ("%(redis:ZCOUNT {%{control.IP-Pool.Name}%}:pool -inf +inf)" == 0) {
-       test_pass
-} else {
+if !("%(redis:ZCOUNT {%{control.IP-Pool.Name}%}:pool -inf +inf)" == 0) {
        test_fail
 }
 
 &reply := {}
+
+test_pass
index 89eaf9a8732ae71d6e0439c78e619dc70162a414..9c52ab08a5e25044d1cc57b1394c969e344423e6 100644 (file)
@@ -13,9 +13,7 @@ $INCLUDE cluster_reset.inc
 #
 #  Verify the range was set OK
 #
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '192.168.0.0') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '192.168.0.0') {
        test_fail
 }
 
@@ -27,8 +25,8 @@ if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '192.168.0
 #
 #  Check it was updated
 #
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '10.0.0.0') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:192.168.0.1 range)" == '10.0.0.0') {
        test_fail
 }
+
+test_pass
index 2621275b9c315dc6319b79e608f8b17fbbf5e8e6..b9c856268abb1eedbe0027ce2053defb28ba2a98 100644 (file)
@@ -16,15 +16,11 @@ $INCLUDE cluster_reset.inc
 redis_ippool {
        invalid = 1
 }
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
-if (&reply.Framed-IP-Address == 192.168.0.1) {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == 192.168.0.1) {
        test_fail
 }
 
@@ -36,38 +32,30 @@ if (&reply.Framed-IP-Address == 192.168.0.1) {
 #
 #  Verify the association with the device has been removed
 #
-if ("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') {
-       test_pass
-} else {
+if !("%(redis:EXISTS {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == '0') {
        test_fail
 }
 
 #
 #  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') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} device)" == '00:11:22:33:44:55') {
        test_fail
 }
 
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
        test_fail
 }
 
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} range)" == '192.168.0.0') {
        test_fail
 }
 
 # Check the ZSCORE
-if ("%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address})" == 0) {
-       test_pass
-} else {
+if !("%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address})" == 0) {
        test_fail
 }
 
 &reply := {}
+
+test_pass
index 3e028ab057183b52aedb5d98545c9d0c62ed1c37..b627afbb6efb30a88f9047febf1c872d81288767 100644 (file)
@@ -12,30 +12,22 @@ $INCLUDE cluster_reset.inc
 
 # 1. Check allocation
 redis_ippool
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
 # 2.
-if (&reply.Framed-IP-Address == 192.168.0.1) {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == 192.168.0.1) {
        test_fail
 }
 
 # 3. Check the expiry attribute is present and correct
-if (&reply.Session-Timeout == 30) {
-       test_pass
-} else {
+if !(&reply.Session-Timeout == 30) {
        test_fail
 }
 
 # 4. Verify the gateway was set
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
        test_fail
 }
 
@@ -48,60 +40,44 @@ if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gatewa
 &control.IP-Pool.Action := Renew
 
 redis_ippool
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
 # 7. Lease time should now be 60 seconds
-if (&reply.Session-Timeout == 60) {
-       test_pass
-} else {
+if !(&reply.Session-Timeout == 60) {
        test_fail
 }
 
 # 8. Check ZSCORE reflects that
 &Tmp-Date-0 := "%l"
 
-if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 50) {
-       test_pass
-} else {
+if !("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 50) {
        test_fail
 }
 
 # 9.
-if ("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 70) {
-       test_pass
-} else {
+if !("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 70) {
        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})") {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})") {
        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) {
-       test_pass
-} else {
+if !("%(redis:TTL {%{control.IP-Pool.Name}}:device:%{Calling-Station-ID})" == 60) {
        test_fail
 }
 
 # 12. Verify the gateway was updated
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{Framed-IP-Address} gateway)" == '127.0.0.2') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{Framed-IP-Address} gateway)" == '127.0.0.2') {
        test_fail
 }
 
 # 13. and that the range attribute was set
-if (&reply.IP-Pool.Range && (&reply.IP-Pool.Range == '192.168.0.0')) {
-       test_pass
-} else {
+if !(&reply.IP-Pool.Range && (&reply.IP-Pool.Range == '192.168.0.0')) {
        test_fail
 }
 
@@ -112,9 +88,7 @@ redis_ippool {
        invalid = 1
 }
 # 14.
-if (notfound) {
-       test_pass
-} else {
+if (!notfound) {
        test_fail
 }
 &Framed-IP-Address := 192.168.0.1
@@ -125,17 +99,15 @@ if (notfound) {
 redis_ippool {
        invalid = 1
 }
-if (invalid) {
-       test_pass
-} else {
+if (!invalid) {
        test_fail
 }
 
 # 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)") {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == "%(redis:GET {%{control.IP-Pool.Name}}:device:00:11:22:33:44:55)") {
        test_fail
 }
 
 &reply := {}
+
+test_pass
index dba651059429d3cdb66bb6997a00ecb5ff339864..042ebf0aca3d78a9aa595ff1a06e7df0478300a4 100644 (file)
@@ -12,9 +12,7 @@ $INCLUDE cluster_reset.inc
 
 # 1. Check allocation
 redis_ippool
-if (updated) {
-       test_pass
-} else {
+if (!updated) {
        test_fail
 }
 
@@ -28,24 +26,20 @@ if (updated) {
 redis_ippool
 
 # 3. Check the expiry attribute is present and correct
-if (&reply.Session-Timeout == 60) {
-       test_pass
-} else {
+if !(&reply.Session-Timeout == 60) {
        test_fail
 }
 
 # 4. Verify the gateway was set
-if ("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
-       test_pass
-} else {
+if !("%(redis:HGET {%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address} gateway)" == '127.0.0.1') {
        test_fail
 }
 
 # 5. Verify we got an IP
-if (&reply.Framed-IP-Address == 192.168.0.1) {
-       test_pass
-} else {
+if !(&reply.Framed-IP-Address == 192.168.0.1) {
        test_fail
 }
 
 &reply := {}
+
+test_pass