# 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
# 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
&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
#
# 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
#
# 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
# expansion.
#
redis_ippool {
- device = &Calling-Station-ID
+ owner = &Calling-Station-ID
gateway = &NAS-IP-Address
pool_name = &control.IP-Pool.Name
#
# 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
#
# 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
#
# 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
#
# 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
#
# 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
#
# 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
#
# 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
#
# 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
&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
}
# 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
&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
}
# 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
}
# 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