]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update redis tests to not use %expr
authorAlan T. DeKok <aland@freeradius.org>
Sun, 8 Oct 2023 12:37:39 +0000 (08:37 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 8 Oct 2023 12:37:39 +0000 (08:37 -0400)
src/tests/modules/redis_ippool/alloc.unlang
src/tests/modules/redis_ippool/update.unlang

index 9b48c3cd27250b12bd543517dfb5caa06173f818..9ffc707eac95226900cd1b7e679746dba507c470 100644 (file)
@@ -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
 }
 
index 99a7a8764c54fb047d62c441ddd45078dd65f516..26b0ecd5e4f6de69d7feba5b6248e7b52d17ab79 100644 (file)
@@ -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
 }