From: Alan T. DeKok Date: Sun, 8 Oct 2023 12:37:39 +0000 (-0400) Subject: update redis tests to not use %expr X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9adfa612b0d3681f4978e470b649542da8b2814c;p=thirdparty%2Ffreeradius-server.git update redis tests to not use %expr --- diff --git a/src/tests/modules/redis_ippool/alloc.unlang b/src/tests/modules/redis_ippool/alloc.unlang index 9b48c3cd27..9ffc707eac 100644 --- a/src/tests/modules/redis_ippool/alloc.unlang +++ b/src/tests/modules/redis_ippool/alloc.unlang @@ -25,28 +25,26 @@ if !(&reply.Framed-IP-Address == 192.168.0.1) { # # Check ZSCORE # -&Tmp-Date-0 := "%l" - -if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 20) { +if ((%redis('ZSCORE', "{%{control.IP-Pool.Name}}:pool", "%{reply.Framed-IP-Address}") - %l) < 20) { test_fail } -if ("%{expr:%(redis:ZSCORE "{%{control.IP-Pool.Name}}:pool" %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" > 40) { +if ((%redis('ZSCORE', "{%{control.IP-Pool.Name}}:pool", "%{reply.Framed-IP-Address}") - %l) > 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') { +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') { +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') { +if !(%redis('HGET', "{%{control.IP-Pool.Name}}:ip:%{reply.Framed-IP-Address}", 'range') == '192.168.0.0') { test_fail } @@ -57,7 +55,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_fail } @@ -106,7 +104,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) { +if ((&Session-Timeout - &reply.Session-Timeout) > 5) { test_fail } diff --git a/src/tests/modules/redis_ippool/update.unlang b/src/tests/modules/redis_ippool/update.unlang index 99a7a8764c..26b0ecd5e4 100644 --- a/src/tests/modules/redis_ippool/update.unlang +++ b/src/tests/modules/redis_ippool/update.unlang @@ -27,7 +27,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_fail } @@ -49,29 +49,27 @@ if !(&reply.Session-Timeout == 60) { } # 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) { +if !((%redis('ZSCORE', "{%{control.IP-Pool.Name}}:pool", "%{reply.Framed-IP-Address}") - %l) > 50) { test_fail } # 9. -if !("%{expr:%(redis:ZSCORE {%{control.IP-Pool.Name}}:pool %{reply.Framed-IP-Address}) - %(integer:%{Tmp-Date-0})}" < 70) { +if !((%redis('ZSCORE', "{%{control.IP-Pool.Name}}:pool", "%{reply.Framed-IP-Address}") - %l) < 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})") { +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) { +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') { +if !(%redis('HGET', "{%{control.IP-Pool.Name}}:ip:%{Framed-IP-Address} gateway") == '127.0.0.2') { test_fail } @@ -103,7 +101,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_fail }