# 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
}
#
&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
}
# 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
}
# 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
}
&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
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
}
#
# 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
#
# 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
}
#
# 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
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
}
#
# 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
# 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
}
&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
}
invalid = 1
}
# 14.
-if (notfound) {
- test_pass
-} else {
+if (!notfound) {
test_fail
}
&Framed-IP-Address := 192.168.0.1
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
# 1. Check allocation
redis_ippool
-if (updated) {
- test_pass
-} else {
+if (!updated) {
test_fail
}
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