+string result_string1
+string result_string2
+
&Vendor-Specific.3GPP.IMSI := "hello"
#
# "request.[0-9]" should be parsed as a list followed
# by an attribute.
#
-&control.Tmp-String-0 := &Vendor-Specific.3GPP.IMSI
-&control.Tmp-String-1 := &Vendor-Specific.3GPP.IMSI
+&result_string1 := &Vendor-Specific.3GPP.IMSI
+&result_string2 := &request.Vendor-Specific.3GPP.IMSI
success
&request += {
- &Tmp-String-0 = "foo"
- &Tmp-String-0 = "bar"
- &Tmp-String-0 = "baz"
+ &Filter-Id = "foo"
+ &Filter-Id = "bar"
+ &Filter-Id = "baz"
}
-&Tmp-String-0[1] := "yellow"
+&Filter-Id[1] := "yellow"
-if (!("%{Tmp-String-0[*]}" == "fooyellowbaz")) {
+if (!("%{Filter-Id[*]}" == "fooyellowbaz")) {
test_fail
}
-&Tmp-String-0[2] += "red"
+&Filter-Id[2] += "red"
-if (!("%{Tmp-String-0[*]}" == "fooyellowbazred")) {
+if (!("%{Filter-Id[*]}" == "fooyellowbazred")) {
test_fail
}
-&Tmp-String-0[2] -= "red"
+&Filter-Id[2] -= "red"
-if (!("%{Tmp-String-0[*]}" == "fooyellowbaz")) {
+if (!("%{Filter-Id[*]}" == "fooyellowbaz")) {
test_fail
}
-&Tmp-String-0[0] := "oof"
-if (!("%{Tmp-String-0[*]}" == "oofyellowbaz")) {
+&Filter-Id[0] := "oof"
+if (!("%{Filter-Id[*]}" == "oofyellowbaz")) {
test_fail
}
-&Tmp-String-0[1] := "bar"
-if (!("%{Tmp-String-0[*]}" == "oofbarbaz")) {
+&Filter-Id[1] := "bar"
+if (!("%{Filter-Id[*]}" == "oofbarbaz")) {
test_fail
}
#
# PRE: if redundant
#
+uint32 test_integer
+string test_string
+ipv4addr test_ipaddr
+ipv4prefix test_ipv4prefix1
+ipv4prefix test_ipv4prefix2
+ipv6addr test_ipv6addr1
+ipv6addr test_ipv6addr2
+ipv6prefix test_ipv6prefix1
+ipv6prefix test_ipv6prefix2
+ipv6prefix test_ipv6prefix3
+
+ipv4addr result_ipaddr
+ipv4prefix result_ipv4prefix
+ipv6addr result_ipv6addr
+ipv6prefix result_ipv6prefix
+
&NAS-IP-Address := 127.0.0.1
-&Tmp-Integer-0 := 0x7f000001
+&test_integer := 0x7f000001
-&Tmp-String-0 := &NAS-IP-Address
+&test_string := &NAS-IP-Address
-if (!((ipaddr)&Tmp-Integer-0[0] == &NAS-IP-Address)) {
+if (!((ipaddr)&test_integer == &NAS-IP-Address)) {
test_fail
}
# correct, by using the assignment to perform the cast, and looking
# at the results.
#
-&request += {
- &Tmp-Cast-Ipaddr = 203.0.113.1
- &Tmp-Cast-IPv4Prefix = 203.0.113.0/24
- &Tmp-Cast-IPv4Prefix = 203.0.113.1/32
- &Tmp-Cast-IPv6Addr = 2001:DB8::1
- &Tmp-Cast-IPv6Addr = ::ffff:203.0.113.1
- &Tmp-Cast-IPv6Prefix = 2001:DB8::/32
- &Tmp-Cast-IPv6Prefix = ::ffff:203.0.113.1/128
- &Tmp-Cast-IPv6Prefix = ::ffff:203.0.113.1/64
-}
+&test_ipaddr = 203.0.113.1
+&test_ipv4prefix1 = 203.0.113.0/24
+&test_ipv4prefix2 = 203.0.113.1/32
+&test_ipv6addr1 = 2001:DB8::1
+&test_ipv6addr2 = ::ffff:203.0.113.1
+&test_ipv6prefix1 = 2001:DB8::/32
+&test_ipv6prefix2 = ::ffff:203.0.113.1/128
+&test_ipv6prefix3 = ::ffff:203.0.113.1/64
#
# IPv4 address to IPv6 address
#
-&control.Tmp-Cast-IPv6addr := &Tmp-Cast-IPaddr[0]
-if (!(&control.Tmp-Cast-IPv6addr[0] == ::ffff:203.0.113.1)) {
+&result_ipv6addr := &test_ipaddr
+if (!(&result_ipv6addr == ::ffff:203.0.113.1)) {
test_fail
}
#
# IPv6 address to IPv4 address
#
-&control.Tmp-Cast-IPaddr := &control.Tmp-Cast-IPv6addr
-if (!(&control.Tmp-Cast-IPaddr[0] == 203.0.113.1)) {
+&result_ipaddr := &result_ipv6addr
+if (!(&result_ipaddr == 203.0.113.1)) {
test_fail
}
#
# IPv4 prefix to IPv6 prefix
#
-&control.Tmp-Cast-IPv6Prefix := &Tmp-Cast-IPv4Prefix[0]
-if (!(&control.Tmp-Cast-IPv6Prefix[0] == ::ffff:203.0.113.0/120)) {
+&result_ipv6prefix := &test_ipv4prefix1
+if (!(&result_ipv6prefix == ::ffff:203.0.113.0/120)) {
test_fail
}
#
# IPv6 prefix to IPv4 prefix
#
-&control.Tmp-Cast-IPv4Prefix := &control.Tmp-Cast-IPv6Prefix[0]
-if (!(&control.Tmp-Cast-IPv4Prefix[0] == 203.0.113.1/24)) {
+&result_ipv4prefix := &result_ipv6prefix
+if (!(&result_ipv4prefix == 203.0.113.1/24)) {
test_fail
}
#
# IPv4 prefix (32) to IPv6 address
#
-&control.Tmp-Cast-IPv6Addr := &Tmp-Cast-IPv4Prefix[1]
-if (!(&control.Tmp-Cast-IPv6Addr[0] == ::ffff:203.0.113.1)) {
+&result_ipv6addr := &test_ipv4prefix2
+if (!(&result_ipv6addr == ::ffff:203.0.113.1)) {
test_fail
}
#
# IPv6 prefix (128) to IPv4 address
#
-&control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv6Prefix[1]
-if (!(&control.Tmp-Cast-Ipaddr[0] == 203.0.113.1/32)) {
+&result_ipaddr := &test_ipv6prefix2
+if (!(&result_ipaddr == 203.0.113.1/32)) {
test_fail
}
#
# IPv4 address to IPv6 prefix (128)
#
-&control.Tmp-Cast-IPv6Prefix := &Tmp-Cast-Ipaddr[0]
-if (!(&control.Tmp-Cast-IPv6Prefix == ::ffff:203.0.113.1/128)) {
+&result_ipv6prefix := &test_ipaddr
+if (!(&result_ipv6prefix == ::ffff:203.0.113.1/128)) {
test_fail
}
#
# IPv6 address to IPv4 prefix (32)
#
-&control.Tmp-Cast-IPv4Prefix[0] := &Tmp-Cast-IPv6Addr[1]
-if (!(&control.Tmp-Cast-IPv4Prefix == 203.0.113.1/32)) {
+&result_ipv4prefix := &test_ipv6addr2
+if (!(&result_ipv4prefix == 203.0.113.1/32)) {
test_fail
}
#
# IPv4 address to IPv4 prefix (32)
#
-&control.Tmp-Cast-IPv4Prefix := &Tmp-Cast-Ipaddr[0]
-if (!(&control.Tmp-Cast-IPv4Prefix == 203.0.113.1/32)) {
+&result_ipv4prefix := &test_ipaddr
+if (!(&result_ipv4prefix == 203.0.113.1/32)) {
test_fail
}
#
# IPv6 address to IPv6 prefix (128)
#
-&control.Tmp-Cast-IPv6Prefix := &Tmp-Cast-Ipv6addr[0]
-if (!(&control.Tmp-Cast-IPv6Prefix == 2001:DB8::1/128)) {
+&result_ipv6prefix := &test_ipv6addr1
+if (!(&result_ipv6prefix == 2001:DB8::1/128)) {
test_fail
}
#
# IPv4 prefix (32) to IPv4 address
#
-&control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv4Prefix[1]
-if (!(&control.Tmp-Cast-Ipaddr == 203.0.113.1)) {
+&result_ipaddr := &test_ipv4prefix2
+if (!(&result_ipaddr == 203.0.113.1)) {
test_fail
}
#
# IPv6 prefix (128) to IPv6 address
#
-&control.Tmp-Cast-IPv6Addr := &Tmp-Cast-IPv6Prefix[1]
-if (!(&control.Tmp-Cast-IPv6Addr == ::ffff:203.0.113.1)) {
+&result_ipv6addr := &test_ipv6prefix2
+if (!(&result_ipv6addr == ::ffff:203.0.113.1)) {
test_fail
}
#
redundant {
group {
- &control.Tmp-Cast-IPv6Addr := &Tmp-Cast-IPv6Prefix[0]
+ &result_ipv6addr := &test_ipv6prefix1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-IPv6Addr failed: Invalid cast from ipv6prefix to ipv6addr. Only /128 (not /32) prefixes may be cast to IP address types') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipv6addr failed: Invalid cast from ipv6prefix to ipv6addr. Only /128 (not /32) prefixes may be cast to IP address types') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv6Prefix[2]
+ &result_ipaddr := &test_ipv6prefix3
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-Ipaddr failed: Invalid cast from ipv6prefix to ipaddr. Only /128 (not /64) prefixes may be cast to IP address types') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipaddr failed: Invalid cast from ipv6prefix to ipaddr. Only /128 (not /64) prefixes may be cast to IP address types') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-Ipv4prefix := &Tmp-Cast-IPv6Prefix[2]
+ &result_ipv4prefix := &test_ipv6prefix3
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-Ipv4prefix failed: Invalid cast from ipv6prefix to ipv4prefix. No IPv4-IPv6 mapping prefix') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipv4prefix failed: Invalid cast from ipv6prefix to ipv4prefix. No IPv4-IPv6 mapping prefix') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-IPv6Addr := &Tmp-Cast-IPv4Prefix[0]
+ &result_ipv6addr := &test_ipv4prefix1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-IPv6Addr failed: Invalid cast from ipv4prefix to ipv6addr. Only /32 (not /24) prefixes may be cast to IP address types') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipv6addr failed: Invalid cast from ipv4prefix to ipv6addr. Only /32 (not /24) prefixes may be cast to IP address types') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv4Prefix[0]
+ &result_ipaddr := &test_ipv4prefix1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-Ipaddr failed: Invalid cast from ipv4prefix to ipaddr. Only /32 (not 24/) prefixes may be cast to IP address types') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipaddr failed: Invalid cast from ipv4prefix to ipaddr. Only /32 (not 24/) prefixes may be cast to IP address types') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv6Prefix[0]
+ &result_ipaddr := &test_ipv6prefix1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-Ipaddr failed: Invalid cast from ipv6prefix to ipaddr. Only /128 (not /32) prefixes may be cast to IP address types') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipaddr failed: Invalid cast from ipv6prefix to ipaddr. Only /128 (not /32) prefixes may be cast to IP address types') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-IPv4prefix := &Tmp-Cast-IPv6Prefix[0]
+ &result_ipv4prefix := &test_ipv6prefix1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-IPv4prefix failed: Invalid cast from ipv6prefix to ipv4prefix. No IPv4-IPv6 mapping prefix') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipv4prefix failed: Invalid cast from ipv6prefix to ipv4prefix. No IPv4-IPv6 mapping prefix') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-Ipaddr := &Tmp-Cast-IPv6Addr[0]
+ &result_ipaddr := &test_ipv6addr1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-Ipaddr failed: Invalid cast from ipv6addr to ipaddr. No IPv4-IPv6 mapping prefix') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipaddr failed: Invalid cast from ipv6addr to ipaddr. No IPv4-IPv6 mapping prefix') {
test_fail
}
&request -= &Module-Failure-Message[*]
#
redundant {
group {
- &control.Tmp-Cast-IPv4prefix := &Tmp-Cast-IPv6Addr[0]
+ &result_ipv4prefix := &test_ipv6addr1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &control.Tmp-Cast-IPv4prefix failed: Invalid cast from ipv6addr to ipv4prefix. No IPv4-IPv6 mapping prefix') {
+ if !(&Module-Failure-Message == 'Assigning value to &result_ipv4prefix failed: Invalid cast from ipv6addr to ipv4prefix. No IPv4-IPv6 mapping prefix') {
test_fail
}
&request -= &Module-Failure-Message[*]
# PRE: if
#
# this fails, so the next edit is merged in and fails, too.
+string result_string
+
&control -= &Password
&control += {
&User-Name = &request.User-Name
&User-Password = &request.User-Password
- &Tmp-String-0 = "ab c"
- &Tmp-String-0 = "de fg"
-# &Tmp-Integer-0 = { 123, 456 } # @todo - Doesn't work :(
- &Tmp-Integer-0 = 123
- &Tmp-Integer-1 = 456
- &Tmp-Integer-1 = 789
+ &Calling-Station-Id = "ab c"
+ &Calling-Station-Id = "de fg"
+# &Port-Limit = { 123, 456 } # @todo - Doesn't work :(
+ &Port-Limit = 123
+ &NAS-Port = 456
+ &NAS-Port = 789
}
#
# (string) (&ref) casts that one value to a string
# and returns one string
#
-&Tmp-String-2 := %{(string) (&control.Tmp-Integer-1[*])}
-if !(&Tmp-String-2 == "456789") {
+&result_string := %{(string) (&control.NAS-Port[*])}
+if !(&result_string == "456789") {
test_fail
}
#
# &ref could return a list.
-# (&ref) means "treat the list as one value"
-# (string) (&ref) casts each value to a string
+# (string) &ref casts each value to a string
# and returns a list of strings
#
-&Tmp-String-2 := %{(string) &control.Tmp-Integer-1[*]}
-if !(&Tmp-String-2[0] == "456") {
+&Called-Station-Id := %{(string) &control.NAS-Port[*]}
+if !(&Called-Station-Id[0] == "456") {
test_fail
}
-if !(&Tmp-String-2[1] == "789") {
+if !(&Called-Station-Id[1] == "789") {
test_fail
}
-&control -= &Tmp-Integer-1[*]
+&control -= &NAS-Port[*]
ok # separate updates
-&control += {
- &Tmp-String-1 = %concat(%{control.[*]}, ', ')
-}
+&result_string := %concat(%{control.[*]}, ', ')
-"%{control.Tmp-String-1}"
-if (!(&control.Tmp-String-1 == "bob, hello, ab c, de fg, 123")) {
+"%{result_string}"
+if (!(&result_string == "bob, hello, ab c, de fg, 123")) {
test_fail
}
-&control += {
- &Tmp-String-2 = %concat(%{control.Tmp-String-0[*]}, ', ')
-}
+&result_string := %concat(%{control.Calling-Station-Id[*]}, ', ')
-if (!(&control.Tmp-String-2 == "ab c, de fg")) {
+if (!(&result_string == "ab c, de fg")) {
test_fail
}
# Empty separator
-&control += {
- &Tmp-String-3 = %concat(%{control.Tmp-String-0[*]})
-}
+&result_string := %concat(%{control.Calling-Station-Id[*]})
-if (!(&control.Tmp-String-3 == "ab cde fg")) {
+if (!(&result_string == "ab cde fg")) {
test_fail
}
# Single character separator
-&control += {
- &Tmp-String-4 = %concat(%{control.Tmp-String-0[*]}, ',')
-}
+&result_string := %concat(%{control.Calling-Station-Id[*]}, ',')
-if (!(&control.Tmp-String-4 == "ab c,de fg")) {
+if (!(&result_string == "ab c,de fg")) {
test_fail
}
# Multi character separator not delimited
-&control += {
- &Tmp-String-5 = %concat(%{control.Tmp-String-0[*]}, '|-')
-}
+&result_string := %concat(%{control.Calling-Station-Id[*]}, '|-')
-if !(&control.Tmp-String-5 == "ab c|-de fg") {
+if !(&result_string == "ab c|-de fg") {
test_fail
}
-&Tmp-String-0 := &reply.Filter-Id[#] # ERROR
+string result_string
+&result_string := &reply.Filter-Id[#] # ERROR
#
# PRE: if
#
+uint32 test_integer
+uint32 result_integer
+string result_string1
+string result_string2
+date test_date
+
# Use pre-defined date and time
-&Tmp-Integer-0 := 1506101100
+&test_integer := 1506101100
# Convert to string representation
-&Tmp-String-0 := %date(%{Tmp-Integer-0})
+&result_string1 := %date(%{test_integer})
# Some systems report GMT some UTC...
-if (!(&Tmp-String-0 == "Fri 22 Sep 17:25:00 GMT 2017")) && (!(&Tmp-String-0 == "Fri 22 Sep 17:25:00 UTC 2017")) {
+if (!(&result_string1 == "Fri 22 Sep 17:25:00 GMT 2017")) && (!(&result_string1 == "Fri 22 Sep 17:25:00 UTC 2017")) {
test_fail
}
# Convert string to integer
-&Tmp-Integer-1 := %date(%{Tmp-String-0})
+&result_integer := %date(%{result_string1})
-if (!(&Tmp-Integer-1 == &Tmp-Integer-0)) {
+if (!(&result_integer == &test_integer)) {
test_fail
}
# Compare two methods of reading request timestamp in local timezone
-&Tmp-String-0 := %localdate(request)
-&Tmp-String-1 := %S
+&result_string1 := %localdate(request)
+&result_string2 := %S
-if (!(&Tmp-String-0 == &Tmp-String-1)) {
+if (!(&result_string1 == &result_string2)) {
test_fail
}
# Convert different string format
-&Tmp-String-2 := "2017-09-22 17:25:00"
+&result_string1 := "2017-09-22 17:25:00"
-&Tmp-Integer-2 := %sqldate(%{Tmp-String-2})
+&result_integer := %sqldate(%{result_string1})
-if (!(&Tmp-Integer-2 == &Tmp-Integer-0)) {
+if (!(&result_integer == &test_integer)) {
test_fail
}
# Use a date attribute
-&Tmp-Date-0 := 1659985459
-&Tmp-String-2 := %sqldate(%{Tmp-Date-0})
+&test_date := 1659985459
+&result_string1 := %sqldate(%{test_date})
-if !(&Tmp-String-2 == '2022-08-08 19:04:19') {
+if !(&result_string1 == '2022-08-08 19:04:19') {
test_fail
}
# Invalid format
-&Tmp-String-3 := '201-32-22 17:25:00'
-&Tmp-String-4 := %sqldate(%{Tmp-String-3})
+&result_string1 := '201-32-22 17:25:00'
+&result_string2 := %sqldate(%{result_string1})
# This shouldn't exist, as the RHS above is NULL, and therefore the assignment will fail
-if (&Tmp-String-4) {
+if (&result_string2) {
test_fail
}
# Invalid type
&NAS-IP-Address := "192.168.1.1"
-&Tmp-String-5 := %date(%{NAS-IP-Address})
+&result_string2 := %date(%{NAS-IP-Address})
-if (&Tmp-String-5) {
+if (&result_string2) {
test_fail
}
#
# PRE: if
#
+uint32 test_integer
+string dummy_string
-&Tmp-Integer-0 := "%debug(4)"
+&test_integer := "%debug(4)"
# Check debug level is now 4
if (!(%debug(3) == 4)) {
}
# Call with NULL arg, should report current level
-if (!(%debug(%{Tmp-String-8}) == 3)) {
+if (!(%debug(%{dummy_string}) == 3)) {
test_fail
}
# ...and again
-if (!(%debug(%{Tmp-String-8}) == 3)) {
+if (!(%debug(%{dummy_string}) == 3)) {
test_fail
}
#
# PRE: if
#
-&Tmp-Integer-0 := 4
-&Tmp-Integer-1 := 6
+uint32 test_integer1
+uint32 test_integer2
+&test_integer1 := 4
+&test_integer2 := 6
#
# Many, many, years of work led up to this!
#
-&Tmp-Integer-0 += 5
+&test_integer1 += 5
-if (!(&Tmp-Integer-0 == 9)) {
+if (!(&test_integer1 == 9)) {
test_fail
}
-&Tmp-Integer-0 += &Tmp-Integer-1
-if (!(&Tmp-Integer-0 == 15)) {
+&test_integer1 += &test_integer2
+if (!(&test_integer1 == 15)) {
test_fail
}
#
# Add to something which doesn't exist
#
+string test_string
+uint32 test_integer1
+uint32 test_integer2
+uint32 test_integer3
-&Tmp-Integer-0 += 4
-if !(&Tmp-Integer-0 == 4) {
+&test_integer1 += 4
+if !(&test_integer1 == 4) {
test_fail
}
-&Tmp-String-0 += "bar"
-if !(&Tmp-String-0 == "bar") {
+&test_string += "bar"
+if !(&test_string == "bar") {
test_fail
}
test_fail
}
-&Tmp-Integer-1 := 3
-&Tmp-Integer-2 := 4
+&test_integer2 := 3
+&test_integer3 := 4
-&Tmp-Integer-0 += &Tmp-Integer-2 - &Tmp-Integer-1
-if !(&Tmp-Integer-0 == 5) {
+&test_integer1 += &test_integer3 - &test_integer2
+if !(&test_integer1 == 5) {
test_fail
}
# Form attribute references with xlats
#
&request += {
- &Tmp-String-0 = 'foo'
- &Tmp-String-0 = 'bar'
- &Tmp-String-1 = 'baz'
+ &Filter-Id = 'foo'
+ &Filter-Id = 'bar'
+ &Calling-Station-Id = 'baz'
}
&control = {}
-if (!(%{Tmp-String-0[#]} == 2)) {
+if (!(%{Filter-Id[#]} == 2)) {
test_fail
}
-if (!(&Tmp-String-0[0] == 'foo')) {
+if (!(&Filter-Id[0] == 'foo')) {
test_fail
}
#
# Delete an attribute by assigning a non-existent attribute to it
#
-&Tmp-String-0[1] := &Reply-Message
+&Filter-Id[1] := &Reply-Message
# Should only remove 'bar'
-if !(&Tmp-String-0[0] == 'foo') {
+if !(&Filter-Id[0] == 'foo') {
test_fail
}
-if (!(&Tmp-String-0[#] == 1)) {
+if (!(&Filter-Id[#] == 1)) {
test_fail
}
# Nothing should exist for this attribute.
-if (&Tmp-String-0[1]) {
+if (&Filter-Id[1]) {
test_fail
}
-if (&Tmp-String-0[2]) {
+if (&Filter-Id[2]) {
test_fail
}
-&Tmp-String-0 := &Reply-Message
+&Filter-Id := &Reply-Message
# All instances should be removed
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
#
# PRE: edit
#
+string test_string1
+string test_string2
+string test_string3
#
# ALl of these edits are grouped. So if one of them fails, all of
# them are rolled back.
#
transaction {
- &Tmp-String-0 := "foo"
- &Tmp-String-1 -= "bar" # fails, no existing Tmp-String-1
- &Tmp-String-2 := "bar"
+ &test_string1 := "foo"
+ &test_string2 -= "bar" # fails, no existing test_string2
+ &test_string3 := "bar"
}
-if (&Tmp-String-0) {
+if (&test_string1) {
test_fail
}
-if (&Tmp-String-1) {
+if (&test_string2) {
test_fail
}
-if (&Tmp-String-2) {
+if (&test_string3) {
test_fail
}
# All of these succeed individually, so all of them should succeed.
#
transaction {
- &Tmp-String-0 := "foo"
- &Tmp-String-1 := "yup"
- &Tmp-String-2 := "bar"
+ &test_string1 := "foo"
+ &test_string2 := "yup"
+ &test_string3 := "bar"
}
-if (!(&Tmp-String-0 == "foo")) {
+if (!(&test_string1 == "foo")) {
test_fail
}
-if (!(&Tmp-String-1 == "yup")) {
+if (!(&test_string2 == "yup")) {
test_fail
}
-if (!(&Tmp-String-2 == "bar")) {
+if (!(&test_string3 == "bar")) {
test_fail
}
# PRE: edit-list
#
-&control.Tmp-String-0 := "foo"
-&reply.Tmp-String-0 := "foo"
+&control.Filter-Id := "foo"
+&reply.Filter-Id := "foo"
&reply &= &control
# must exist
-if (!&reply.Tmp-String-0) {
+if (!&reply.Filter-Id) {
test_fail
}
# and have the correct value
-if (!(&reply.Tmp-String-0 == "foo")) {
+if (!(&reply.Filter-Id == "foo")) {
test_fail
}
# reset
-&reply -= &Tmp-String-0[*]
+&reply -= &Filter-Id[*]
#
# Same attribute, but different value
#
-&reply.Tmp-String-0 := "bar"
+&reply.Filter-Id := "bar"
&reply &= &control
# must NOT exist
-if (&reply.Tmp-String-0) {
+if (&reply.Filter-Id) {
test_fail
}
-&Tmp-String-0 := "foo"
-&Tmp-String-1 := &Tmp-String-0
-&Tmp-String-2 := "Tmp-String-0"
+string test_string1
+string test_string2
+string test_string3
+
+&test_string1 := "foo"
+&test_string2 := &test_string1
+&test_string3 := "test_string1"
# foo, bar, "foo", "foo"
-&Tmp-String-3 := { &Tmp-String-0, "bar", "%{Tmp-String-0}", %{Tmp-String-2} }
+&Filter-Id := { &test_string1, "bar", "%{test_string1}", %{test_string3} }
-if (!(%{Tmp-String-3[#]} == 4)) {
+if (!(%{Filter-Id[#]} == 4)) {
test_fail
}
-if (!("%{Tmp-String-3[*]}" == "foobarfooTmp-String-0")) {
+if (!("%{Filter-Id[*]}" == "foobarfootest_string1")) {
test_fail
}
#
# PRE: edit
#
-&Tmp-String-0 := {
+&Filter-Id := {
"foo %{User-Name}",
"bar",
"baz",
&User-Name
}
-if (!(%{request.Tmp-String-0[#]} == 4)) {
+if (!(%{request.Filter-Id[#]} == 4)) {
test_fail
}
-if (!(&Tmp-String-0[0] == "foo bob")) {
+if (!(&Filter-Id[0] == "foo bob")) {
test_fail
}
-if (!(&Tmp-String-0[1] == "bar")) {
+if (!(&Filter-Id[1] == "bar")) {
test_fail
}
-if (!(&Tmp-String-0[2] == "baz")) {
+if (!(&Filter-Id[2] == "baz")) {
test_fail
}
-if (!(&Tmp-String-0[3] == "bob")) {
+if (!(&Filter-Id[3] == "bob")) {
test_fail
}
#
# And test non-string things
#
-&Tmp-String-0 := "127"
+&Filter-Id := "127"
&Framed-IP-Address := {
- "%{Tmp-String-0}.0.0.1",
+ "%{Filter-Id}.0.0.1",
192.0.2.1
}
#
# PRE: edit
#
-&Tmp-Integer-0 := { 1, 3, 5, 7, 11 }
+uint32 result_integer
-&Tmp-Integer-1 := 0
+&NAS-Port := { 1, 3, 5, 7, 11 }
#
# Do operations on sets of inputs.
#
-&Tmp-Integer-1 += &Tmp-Integer-0[*]
-if (!(&Tmp-Integer-1 == 27)) {
+&result_integer += &NAS-Port[*]
+if (!(&result_integer == 27)) {
test_fail
}
#
# We should be able to copy multiple attributes
#
-&Tmp-Integer-2 := &Tmp-Integer-0[*]
-&Tmp-Integer-1 := 0
+&Port-Limit := &NAS-Port[*]
+&result_integer := 0
#
# Do operations on sets of inputs.
#
-&Tmp-Integer-1 += &Tmp-Integer-2[*]
-if (!(&Tmp-Integer-1 == 27)) {
+&result_integer += &Port-Limit[*]
+if (!(&result_integer == 27)) {
test_fail
}
# PRE: edit
#
-&control.Tmp-String-0 := "foo"
+&control.Filter-Id := "foo"
# Doesn't exist
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
&request += &control
# Does exist, and is the last attribute
-if (!&Tmp-String-0[n]) {
+if (!&Filter-Id[n]) {
test_fail
}
-&request -= &Tmp-String-0[*]
+&request -= &Filter-Id[*]
# Doesn't exist
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
&request ^= &control
# Does exist, and is at offset 0
-if (!&Tmp-String-0[0]) {
+if (!&Filter-Id[0]) {
test_fail
}
-&request -= &Tmp-String-0[*]
-&control.Tmp-String-0 := { "a", "b", "c", "d" }
+&request -= &Filter-Id[*]
+&control.Filter-Id := { "a", "b", "c", "d" }
-&request += &control.Tmp-String-0[*]
-if (!(%{request.Tmp-String-0[#]} == 4)) {
+&request += &control.Filter-Id[*]
+if (!(%{request.Filter-Id[#]} == 4)) {
test_fail
}
#
&request += {
- &Tmp-Octets-0 = 0x00
- &Tmp-String-0 = "foo"
- &Tmp-Integer-0 = 1
+ &Class = 0x00
+ &Filter-Id = "foo"
+ &NAS-Port = 1
}
# Does exist
-if (!&Tmp-String-0) {
+if (!&Filter-Id) {
test_fail
}
# Remove the first one
-&request -= &Tmp-String-0
+&request -= &Filter-Id
# Does not exist
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
# Other things still exist
-if (!&Tmp-Octets-0) {
+if (!&Class) {
test_fail
}
-if (!&Tmp-Integer-0) {
+if (!&NAS-Port) {
test_fail
}
# Add multiple of the same type
#
&request += {
- &Tmp-String-0 = "foo"
- &Tmp-String-0 = "bar"
- &Tmp-String-0 = "baz"
+ &Filter-Id = "foo"
+ &Filter-Id = "bar"
+ &Filter-Id = "baz"
}
-if (!&Tmp-String-0) {
+if (!&Filter-Id) {
test_fail
}
-&request -= &Tmp-String-0[0]
+&request -= &Filter-Id[0]
# the first one has been removed
-if (!(&Tmp-String-0[0] == "bar")) {
+if (!(&Filter-Id[0] == "bar")) {
test_fail
}
# Other things still exist
-if (!&Tmp-Octets-0) {
+if (!&Class) {
test_fail
}
-if (!&Tmp-Integer-0) {
+if (!&NAS-Port) {
test_fail
}
-&request -= &Tmp-String-0[*]
+&request -= &Filter-Id[*]
# Does not exist
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
-&Tmp-String-0 := { "foo", "bar", "baz" }
+&Filter-Id := { "foo", "bar", "baz" }
#
# Remove one by value.
# as a condition? For now, it's an exact match. :(
#
&request -= {
- &Tmp-String-0 == "bar"
+ &Filter-Id == "bar"
}
-if (!(&Tmp-String-0[0] == "foo")) {
+if (!(&Filter-Id[0] == "foo")) {
test_fail
}
-if (!(&Tmp-String-0[1] == "baz")) {
+if (!(&Filter-Id[1] == "baz")) {
test_fail
}
-if (&Tmp-String-0[2]) {
+if (&Filter-Id[2]) {
test_fail
}
#
# Remove via in-place list, too.
#
-&request -= "Tmp-String-0 == 'foo'"
-if (!(&Tmp-String-0[0] == "baz")) {
+&request -= "Filter-Id == 'foo'"
+if (!(&Filter-Id[0] == "baz")) {
test_fail
}
-if (&Tmp-String-0[1]) {
+if (&Filter-Id[1]) {
test_fail
}
# PRE: edit-list
#
-&control.Tmp-String-0 := "foo"
+&control.Filter-Id := "foo"
# must exist
-if (!&control.Tmp-String-0) {
+if (!&control.Filter-Id) {
test_fail
}
&control := {}
# must not exist
-if (&control.Tmp-String-0) {
+if (&control.Filter-Id) {
test_fail
}
#
# PRE: edit-leaf-star
#
-&Tmp-Group-0.Tmp-Integer-0 := { 1, 3, 5, 7, 11 }
-&Tmp-Integer-1 := 0
+&Tmp-Group-0.NAS-Port := { 1, 3, 5, 7, 11 }
+&Port-Limit := 0
#
# Do operations on sets of inputs.
#
-&Tmp-Integer-1 += &Tmp-Group-0.Tmp-Integer-0[*]
-if (!(&Tmp-Integer-1 == 27)) {
+&Port-Limit += &Tmp-Group-0.NAS-Port[*]
+if (!(&Port-Limit == 27)) {
test_fail
}
&Tmp-Group-1 := &Tmp-Group-0
-&Tmp-Integer-1 := 0
+&Port-Limit := 0
-&Tmp-Integer-1 += &Tmp-Group-1.Tmp-Integer-0[*]
-if (!(&Tmp-Integer-1 == 27)) {
+&Port-Limit += &Tmp-Group-1.NAS-Port[*]
+if (!(&Port-Limit == 27)) {
test_fail
}
#
# The purpose of this functionality is mainly for xlat, exec, etc.
#
-&control += "Tmp-Integer-0 = 9"
+&control += "NAS-Port = 9"
-if (!(&control.Tmp-Integer-0 == 9)) {
+if (!(&control.NAS-Port == 9)) {
test_fail
}
# = A' MERGE B' if A and B are lists
#
-&Tmp-String-0 := "foo"
-&control.Tmp-String-0 := "bar"
+&Filter-Id := "foo"
+&control.Filter-Id := "bar"
# merge
&request >= &control
-if (!&Tmp-String-0) {
+if (!&Filter-Id) {
test_fail
}
# The original value should be unchanged
-if (!(&Tmp-String-0 == "foo")) {
+if (!(&Filter-Id == "foo")) {
test_fail
}
# and the new value should not be there
-if (&Tmp-String-0 == "bar") {
+if (&Filter-Id == "bar") {
test_fail
}
# = A' MERGE B' if A and B are lists
#
-&Tmp-String-0 := "foo"
-&control.Tmp-String-0 := "bar"
+&Filter-Id := "foo"
+&control.Filter-Id := "bar"
# merge
&request <= &control
-if (!&Tmp-String-0) {
+if (!&Filter-Id) {
test_fail
}
# we want the *control* version
-if (!(&Tmp-String-0 == "bar")) {
+if (!(&Filter-Id == "bar")) {
test_fail
}
# and the original value should not be there
-if (&Tmp-String-0 == "foo") {
+if (&Filter-Id == "foo") {
test_fail
}
# &request, etc. for now. We should support more.
#
&control.Tmp-Group-0 := {
- &Tmp-Integer-0 = 1
+ &NAS-Port = 1
}
-if (!&control.Tmp-Group-0.Tmp-Integer-0) {
+if (!&control.Tmp-Group-0.NAS-Port) {
test_fail
}
-if (!(&control.Tmp-Group-0.Tmp-Integer-0 == 1)) {
+if (!(&control.Tmp-Group-0.NAS-Port == 1)) {
test_fail
}
#
# Edit it in place.
#
-&control.Tmp-Group-0.Tmp-Integer-0 += 5
+&control.Tmp-Group-0.NAS-Port += 5
-if (!(&control.Tmp-Group-0.Tmp-Integer-0 == 6)) {
+if (!(&control.Tmp-Group-0.NAS-Port == 6)) {
test_fail
}
#
# @todo - look FIRST for attributes in the current group?
#
-&control.Tmp-Group-0 -= &control.Tmp-Group-0.Tmp-Integer-0
+&control.Tmp-Group-0 -= &control.Tmp-Group-0.NAS-Port
-if (&control.Tmp-Group-0.Tmp-Integer-0) {
+if (&control.Tmp-Group-0.NAS-Port) {
test_fail
}
# Append something to it
#
&control.Tmp-Group-0 += {
- &Tmp-IP-Address-0 = 127.0.0.1
+ &Framed-IP-Address = 127.0.0.1
}
-if (!(&control.Tmp-Group-0.Tmp-IP-Address-0 == 127.0.0.1)) {
+if (!(&control.Tmp-Group-0.Framed-IP-Address == 127.0.0.1)) {
test_fail
}
# Multiple members
#
&control.Tmp-Group-0 += {
- &Tmp-Octets-0 = 0xabcdef
+ &Class = 0xabcdef
}
-if (!(&control.Tmp-Group-0.Tmp-IP-Address-0 == 127.0.0.1)) {
+if (!(&control.Tmp-Group-0.Framed-IP-Address == 127.0.0.1)) {
test_fail
}
-if (!(&control.Tmp-Group-0.Tmp-Octets-0 == 0xabcdef)) {
+if (!(&control.Tmp-Group-0.Class == 0xabcdef)) {
test_fail
}
# PRE: if edit
#
&request += {
- &Tmp-IP-Address-0 = 192.0.2.1
- &Tmp-IP-Address-0 = 192.0.2.2
+ &Framed-IP-Address = 192.0.2.1
+ &Framed-IP-Address = 192.0.2.2
}
#
# Delete only the second one
#
-&request.Tmp-IP-Address-0[1] := {}
+&request.Framed-IP-Address[1] := {}
-if (&Tmp-IP-Address-0[#] != 1) {
+if (&Framed-IP-Address[#] != 1) {
test_fail
}
-if !(&Tmp-IP-Address-0[0] == 192.0.2.1) {
+if !(&Framed-IP-Address[0] == 192.0.2.1) {
test_fail
}
#
# The RHS isn't a number or an enum
#
-&Tmp-Integer-0 := '$[3][2]' # ERROR
\ No newline at end of file
+uint32 a
+&a := '$[3][2]' # ERROR
#
# PRE: edit
#
-&Tmp-String-0 := "foo"
-&Tmp-String-0 ^= "bar"
+string test_string
+&test_string := "foo"
+&test_string ^= "bar"
-if (!(&Tmp-String-0 == "barfoo")) {
+if (!(&test_string == "barfoo")) {
test_fail
}
-&Tmp-String-0 := "foo"
-&Tmp-String-0 += "bar"
+&test_string := "foo"
+&test_string += "bar"
-if (!(&Tmp-String-0 == "foobar")) {
+if (!(&test_string == "foobar")) {
test_fail
}
#
# Subtract is the inverse of add.
#
-&Tmp-String-0 -= "bar"
+&test_string -= "bar"
-if (!(&Tmp-String-0 == "foo")) {
+if (!(&test_string == "foo")) {
test_fail
}
# = A' UNION B' if A and B are lists
#
-&Tmp-String-0 := "foo"
-&control.Tmp-String-0 := "bar"
+&Reply-Message := "foo"
+&control.Reply-Message := "bar"
# union
&request |= &control
-if (!&Tmp-String-0) {
+if (!&Reply-Message) {
test_fail
}
# The original value should be unchanged
-if (!(&Tmp-String-0[0] == "foo")) {
+if (!(&Reply-Message[0] == "foo")) {
test_fail
}
# and the new value should be there, too
-if (!(&Tmp-String-0[1] == "bar")) {
+if (!(&Reply-Message[1] == "bar")) {
test_fail
}
#
# PRE: if xlat-attr-index
#
-&Tmp-String-0 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /'
-&Tmp-String-1 := '±§#$%^&+={[}];<,>?`|"'
-&Tmp-String-2 := '™¥¤'
-&Tmp-String-3 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22'
-&Tmp-String-4 := '=E2=84=A2=C2=A5=C2=A4'
-&Tmp-String-5 := '=40=61=62=63=64=65=66=67'
+string test_string1
+string test_string2
+string test_string3
+string test_string4
+string test_string5
+string test_string6
+string test_string7
+string test_string8
+string test_string9
+
+&test_string1 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /'
+&test_string2 := '±§#$%^&+={[}];<,>?`|"'
+&test_string3 := '™¥¤'
+&test_string4 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22'
+&test_string5 := '=E2=84=A2=C2=A5=C2=A4'
+&test_string6 := '=40=61=62=63=64=65=66=67'
# Mixture of safe and unsafe chars
-&Tmp-String-6 := 'ŒČÿ'
-&Tmp-String-7 := 'Œ=C4=8Cÿ'
+&test_string7 := 'ŒČÿ'
+&test_string8 := 'Œ=C4=8Cÿ'
# = not followed by hex and without 2 following chars
-&Tmp-String-8 := 'a=Az=y'
+&test_string9 := 'a=Az=y'
-if (!((string)%escape.escape("%{Tmp-String-0}") == &Tmp-String-0)) {
+if (!((string)%escape.escape("%{test_string1}") == &test_string1)) {
test_fail
}
-if (!((string)%escape.escape("%{Tmp-String-1}") == &Tmp-String-3)) {
+if (!((string)%escape.escape("%{test_string2}") == &test_string4)) {
test_fail
}
-if (!((string)%escape.escape("%{Tmp-String-2}") == &Tmp-String-4)) {
+if (!((string)%escape.escape("%{test_string3}") == &test_string5)) {
test_fail
}
-if (!((string)%escape.unescape("%{Tmp-String-0}") == &Tmp-String-0)) {
+if (!((string)%escape.unescape("%{test_string1}") == &test_string1)) {
test_fail
}
-if (!((string)%escape.unescape("%{Tmp-String-3}") == "%{Tmp-String-1}")) {
+if (!((string)%escape.unescape("%{test_string4}") == "%{test_string2}")) {
test_fail
}
-if (!((string)%escape.unescape("%{Tmp-String-4}") == &Tmp-String-2)) {
+if (!((string)%escape.unescape("%{test_string5}") == &test_string3)) {
test_fail
}
-if (!((string)%escape.escape("%{Tmp-String-6}") == &Tmp-String-7)) {
+if (!((string)%escape.escape("%{test_string7}") == &test_string8)) {
test_fail
}
-if (!((string)%escape.unescape("%{Tmp-String-7}") == &Tmp-String-6)) {
+if (!((string)%escape.unescape("%{test_string8}") == &test_string7)) {
test_fail
}
-if (!((string)%escape.unescape("%{Tmp-String-8}") == &Tmp-String-8)) {
+if (!((string)%escape.unescape("%{test_string9}") == &test_string9)) {
test_fail
}
#
# PRE: if xlat-attr-index
#
+octets test_octets
+ipaddr test_ipaddr
+string result_string
+
+&test_octets := 0x69206861766520736361727920656d626564646564207468696e67730020696e73696465206d65
+&test_ipaddr := 127.0.0.1
&request += {
- &Tmp-Octets-0 = 0x69206861766520736361727920656d626564646564207468696e67730020696e73696465206d65
- &Tmp-Octets-1 = 0x30783031013078303707307830410A307830440D222230786230b0C2b0
- &Tmp-String-0 = "i have scary embedded things\000 inside me"
- &Tmp-String-0 = "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°"
+ &Reply-Message = "i have scary embedded things\000 inside me"
+ &Reply-Message = "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°"
# and again with single quoted strings.
# unlike other languages, \r, \t, and \n have meaning inside of 'string'
- &Tmp-String-1 = 'i have scary embedded things\000 inside me'
- &Tmp-String-1 = '0x01\0010x07\0070x0A\n0x0D\r""0xb0\260°'
-
- &Tmp-String-2 = 'i have scary embedded things\000 inside me'
- &Tmp-String-2 = "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°"
+ &Callback-Number = 'i have scary embedded things\000 inside me'
+ &Callback-Number = '0x01\0010x07\0070x0A\n0x0D\r""0xb0\260°'
- &Tmp-IP-Address-0 = 127.0.0.1
+ &Callback-Id = 'i have scary embedded things\000 inside me'
+ &Callback-Id = "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°"
}
-if (!("%length(%{Tmp-String-0})" == 39)) {
+if (!("%length(%{Reply-Message})" == 39)) {
test_fail
}
-if (!("%length(%{Tmp-String-1})" == 42)) {
+if (!("%length(%{Callback-Number})" == 42)) {
test_fail
}
-&Tmp-String-8 := "%{(string) %{Tmp-Octets-0}}"
-if (!(&Tmp-String-8 == "i have scary embedded things\000 inside me")) {
+&result_string := "%{(string) %{test_octets}}"
+if (!(&result_string == "i have scary embedded things\000 inside me")) {
test_fail
}
-if (!(&Tmp-String-0 == "i have scary embedded things\000 inside me")) {
+if (!(&Reply-Message == "i have scary embedded things\000 inside me")) {
test_fail
}
-&Tmp-String-8 := "%{(string) %{Tmp-Octets-1}}"
-if (!(&Tmp-String-8 == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
+&test_octets := 0x30783031013078303707307830410A307830440D222230786230b0C2b0
+&result_string := "%{(string) %{test_octets}}"
+if (!(&result_string == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
test_fail
}
-if (!("%{Tmp-String-0[0]}" == "i have scary embedded things\000 inside me")) {
+if (!("%{Reply-Message[0]}" == "i have scary embedded things\000 inside me")) {
test_fail
}
-if (!(&Tmp-String-0[1] == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
+if (!(&Reply-Message[1] == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
test_fail
}
# And another slightly different codepath...
-if !("%{Tmp-String-0[*]}" == "i have scary embedded things\000 inside me0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°") {
+if !("%{Reply-Message[*]}" == "i have scary embedded things\000 inside me0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°") {
test_fail
}
-if (!(&Tmp-String-0[0] == &Tmp-String-0[0])) {
+if (!(&Reply-Message[0] == &Reply-Message[0])) {
test_fail
}
# This seems weird... double escapes for most things, but single escapes
# for the quotation marks.
#
-if (!(&Tmp-String-2[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) {
+if (!(&Callback-Id[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) {
test_fail
}
#
# And again as an attribute reference
#
-if (!(&Tmp-String-2[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) {
+if (!(&Callback-Id[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) {
test_fail
}
#
# Other data types
#
-&Tmp-String-0 := "%{(string) &Tmp-IP-Address-0}"
-if (!(%length(%{Tmp-String-0}) == 9)) {
+&result_string := "%{(string) &test_ipaddr}"
+if (!(%length(%{result_string}) == 9)) {
test_fail
}
-&request += {
- &Tmp-Ethernet-0 = 00:11:22:33:44:54,
- &Tmp-Ethernet-0 = 00:11:22:33:44:55,
- &Tmp-Octets-0 = 0x001122334456,
-}
+octets test_octets
+ether test_ether
-if (!(&Tmp-Ethernet-0[0] == 00:11:22:33:44:54)) {
- test_fail
-}
+&test_octets := 0x001122334456
-if (!(&Tmp-Ethernet-0[1] == 00:11:22:33:44:55)) {
- test_fail
-}
-
-&request += {
- &Tmp-Ethernet-0 = &Tmp-Octets-0[0]
-}
+&test_ether = &test_octets
-if (!(&Tmp-Ethernet-0[2] == 00:11:22:33:44:56)) {
+if (!(&test_ether == 00:11:22:33:44:56)) {
test_fail
}
# invalid assignment
# this will silently fail with a no Module-Failure-Message.
transaction {
- &request += {
- &Tmp-Ethernet-0 = %{Tmp-Ethernet-1[42]}
- }
+ &test_ether := %{Class[42]}
}
-if (!(%{request.Tmp-Ethernet-0[#]} == 3)) {
+if (&test_ether) {
test_fail
}
#
# PRE: if
#
+uint32 test_integer1
+uint32 test_integer2
+date test_date
#
# Simple
#
# attribute references
#
-&Tmp-Integer-0 := 1
-&Tmp-Integer-1 := 3
-&Tmp-Integer-2 := 4
-&Tmp-Date-0 := "%l"
+&test_integer1 := 3
+&test_integer2 := 4
+&test_date := "%l"
-if (!(%{ 1 + 2 * &Tmp-Integer-1 + 4} == 11)) {
+if (!(%{ 1 + 2 * &test_integer1 + 4} == 11)) {
test_fail
}
-if !(1 + 2 * &Tmp-Integer-1 + 4 == 11) {
+if !(1 + 2 * &test_integer1 + 4 == 11) {
test_fail
}
-if (!(%{ 1 + 2 * (&Tmp-Integer-1 + 4)} == 15)) {
+if (!(%{ 1 + 2 * (&test_integer1 + 4)} == 15)) {
test_fail
}
-if !(1 + 2 * (&Tmp-Integer-1 + 4) == 15) {
+if !(1 + 2 * (&test_integer1 + 4) == 15) {
test_fail
}
-if (!(%{ 1 + 2 * (&Tmp-Integer-1 + &Tmp-Integer-2)} == 15)) {
+if (!(%{ 1 + 2 * (&test_integer1 + &test_integer2)} == 15)) {
test_fail
}
-if !(1 + 2 * (&Tmp-Integer-1 + &Tmp-Integer-2) == 15) {
+if !(1 + 2 * (&test_integer1 + &test_integer2) == 15) {
test_fail
}
test_fail
}
-if ("%{ &Tmp-Date-0}" <= 0) {
+if ("%{ &test_date}" <= 0) {
test_fail
}
-if (&Tmp-Date-0 <= 0) {
+if (&test_date <= 0) {
test_fail
}
test_fail
}
-if (!(%{ 6 * -&Tmp-Integer-2} == -24)) {
+if (!(%{ 6 * -&test_integer2} == -24)) {
test_fail
}
-if !(6 * -&Tmp-Integer-2 == -24) {
+if !(6 * -&test_integer2 == -24) {
test_fail
}
#
# PRE: foreach foreach-break
#
+string test_string
-&Tmp-String-0 := "ABCDEF_8"
+&test_string := "ABCDEF_8"
#
-# This creates a bunch of Tmp-String-0 attributes.
+# This creates a bunch of User-Name attributes.
#
-&control.Tmp-String-0 := { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g" }
+&control.User-Name := { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g" }
-foreach &control.Tmp-String-0 {
- if ("%{Tmp-String-0[*]}" =~ /([A-Z0-9\-]*)_%{Foreach-Variable-0}/) {
- &Tmp-String-0 := "%{1}"
+foreach &control.User-Name {
+ if ("%{test_string}" =~ /([A-Z0-9\-]*)_%{Foreach-Variable-0}/) {
+ &test_string := "%{1}"
success
break
}
# PRE: foreach
#
-&control.Tmp-String-0 := { "0", "1", "2", "3" }
+&control.User-Name := { "0", "1", "2", "3" }
-foreach &control.Tmp-String-0 {
+foreach &control.User-Name {
&control -= {
- &Tmp-String-0 == "%{1 + %{Foreach-Variable-0}}"
+ &User-Name == "%{1 + %{Foreach-Variable-0}}"
}
&request += {
- &Tmp-String-0 = "%{Foreach-Variable-0}"
+ &Filter-Id = "%{Foreach-Variable-0}"
}
}
-if (!&Tmp-String-0[0] || !&Tmp-String-0[1] || !&Tmp-String-0[2] || !&Tmp-String-0[3]) {
+if (!&Filter-Id[0] || !&Filter-Id[1] || !&Filter-Id[2] || !&Filter-Id[3]) {
test_fail
}
-if (!((&Tmp-String-0[0] == '0')) || (!(&Tmp-String-0[1] == '1')) || (!(&Tmp-String-0[2] == '2')) || (!(&Tmp-String-0[3] == '3'))) {
+if (!((&Filter-Id[0] == '0')) || (!(&Filter-Id[1] == '1')) || (!(&Filter-Id[2] == '2')) || (!(&Filter-Id[3] == '3'))) {
test_fail
}
-if (!&control.Tmp-String-0[0] || &control.Tmp-String-0[1] || &control.Tmp-String-0[2] || &control.Tmp-String-0[3]) {
+if (!&control.User-Name[0] || &control.User-Name[1] || &control.User-Name[2] || &control.User-Name[3]) {
test_fail
}
# PRE: foreach if-regex-match
+string cisco_prefix
# This is what most people end up using foreach for,
# so we should probably test it works.
-&Tmp-String-0 := "cisco"
+&cisco_prefix := "cisco"
# Expanded regex
foreach &Vendor-Specific.Cisco.AVPair {
- if ("%{Foreach-Variable-0}" =~ /^%{Tmp-String-0}=(.*)$/i) {
+ if ("%{Foreach-Variable-0}" =~ /^%{cisco_prefix}=(.*)$/i) {
&reply += {
&Called-Station-Id = "%{1}"
}
# PRE: foreach
#
&control += {
- &Tmp-String-0 = "ssid=ABCDEF"
- &Tmp-String-0 = "ssid=GHIJKL"
+ &Filter-Id = "ssid=ABCDEF"
+ &Filter-Id = "ssid=GHIJKL"
}
if (&User-Name) {
- foreach &control.Tmp-String-0 {
+ foreach &control.Filter-Id {
if ("%{Foreach-Variable-0}" =~ /(.*)/) {
- &control.Tmp-String-1 := "%{1}"
+ &control.Calling-Station-Id := "%{1}"
}
}
}
-if (!(&control.Tmp-String-1 == 'ssid=GHIJKL')) {
+if (!(&control.Calling-Station-Id == 'ssid=GHIJKL')) {
test_fail
}
-&control -= &Tmp-String-1[*]
+&control -= &Calling-Station-Id[*]
-foreach &control.Tmp-String-0 {
+foreach &control.Filter-Id {
if ("%{Foreach-Variable-0}" =~ /(.*)/) {
- &control.Tmp-String-1 := "%{1}"
+ &control.Calling-Station-Id := "%{1}"
}
}
-if (!(&control.Tmp-String-1 == 'ssid=GHIJKL')) {
+if (!(&control.Calling-Station-Id == 'ssid=GHIJKL')) {
test_fail
}
-&control -= &Tmp-String-1[*]
+&control -= &Calling-Station-Id[*]
success
#
# PRE: if
#
-&Tmp-String-0 := '9870'
-&Tmp-Octets-0 := 0x39383731
-&Tmp-IP-Address-0 := 57.56.55.50
-&Tmp-Integer-0 := 959985460
-&Tmp-Cast-IfId := '0000:0000:3938:3737'
-&Tmp-Cast-IPv6Addr := '::3938:3738'
-&Tmp-Cast-IPv6Prefix := '::3938:3739/128'
-&Tmp-Cast-Byte := 58
-&Tmp-Cast-Short := 14139
-&Tmp-Cast-Ether := 00:00:39:38:37:3c
-&Tmp-Cast-Integer64 := 1152921505566832445
-&Tmp-Cast-IPv4Prefix := 57.56.55.62/32
-
-ok # break up edit sections
-
-&Tmp-String-1 := {
- %hex(%{Tmp-String-0})
- %hex(%{Tmp-Octets-0})
- %hex(%{Tmp-IP-Address-0})
- %hex(%{Tmp-Integer-0})
- %hex(%{Tmp-Cast-Ifid})
- %hex(%{Tmp-Cast-IPv6Addr})
- %hex(%{Tmp-Cast-IPv6Prefix})
- %hex(%{Tmp-Cast-Byte})
-}
+string test_string
+octets test_octets
+ipaddr test_ipaddr
+uint32 test_integer
+ifid test_ifid
+ipv6addr test_ipv6addr
+ipv6prefix test_ipv6prefix
+byte test_byte
+uint16 test_short
+ether test_ether
+uint64 test_int64
+ipv4prefix test_ipv4prefix
+
+string result_string
+
+&test_string := '9870'
+&test_octets := 0x39383731
+&test_ipaddr := 57.56.55.50
+&test_integer := 959985460
+&test_ifid := '0000:0000:3938:3737'
+&test_ipv6addr := '::3938:3738'
+&test_ipv6prefix := '::3938:3739/128'
+&test_byte := 58
+&test_short := 14139
+&test_ether := 00:00:39:38:37:3c
+&test_int64 := 1152921505566832445
+&test_ipv4prefix := 57.56.55.62/32
# String
-if (!(&Tmp-String-1[0] == '39383730')) {
+&result_string := %hex(%{test_string})
+if (!(&result_string == '39383730')) {
test_fail
}
# Octets
-if (!(&Tmp-String-1[1] == '39383731')) {
+&result_string := %hex(%{test_octets})
+if (!(&result_string == '39383731')) {
test_fail
}
# IP Address
-if (!(&Tmp-String-1[2] == '39383732')) {
+&result_string := %hex(%{test_ipaddr})
+if (!(&result_string == '39383732')) {
test_fail
}
# Integer
-if (!(&Tmp-String-1[3] == '39383734')) {
+&result_string := %hex(%{test_integer})
+if (!(&result_string == '39383734')) {
test_fail
}
# ifid
-if (!(&Tmp-String-1[4] == '0000000039383737')) {
+&result_string := %hex(%{test_ifid})
+if (!(&result_string == '0000000039383737')) {
test_fail
}
# ipv6addr
-if (!(&Tmp-String-1[5] == '00000000000000000000000039383738')) {
+&result_string := %hex(%{test_ipv6addr})
+if (!(&result_string == '00000000000000000000000039383738')) {
test_fail
}
# ipv6addrprefix
-if (!(&Tmp-String-1[6] == '008000000000000000000000000039383739')) {
+&result_string := %hex(%{test_ipv6prefix})
+if (!(&result_string == '008000000000000000000000000039383739')) {
test_fail
}
# byte
-if (!(&Tmp-String-1[7] == '3a')) {
+&result_string := %hex(%{test_byte})
+if (!(&result_string == '3a')) {
test_fail
}
-&Tmp-String-1 := {
- %hex(%{Tmp-Cast-Short})
- %hex(%{Tmp-Cast-Ether})
- %hex(%{Tmp-Cast-Integer64})
- %hex(%{Tmp-Cast-IPv4Prefix})
-}
-
# short
-if (!(&Tmp-String-1[0] == '373b')) {
+&result_string := %hex(%{test_short})
+if (!(&result_string == '373b')) {
test_fail
}
# ethernet
-if (!(&Tmp-String-1[1] == '00003938373c')) {
+&result_string := %hex(%{test_ether})
+if (!(&result_string == '00003938373c')) {
test_fail
}
# integer64
-if (!(&Tmp-String-1[2] == '100000003938373d')) {
+&result_string := %hex(%{test_int64})
+if (!(&result_string == '100000003938373d')) {
test_fail
}
# ipv4prefix
-if (!(&Tmp-String-1[3] == '203938373e')) {
- test_fail
-}
-
-# Empty input
-if (&Tmp-String-1[4]) {
+&result_string := %hex(%{test_ipv4prefix})
+if (!(&result_string == '203938373e')) {
test_fail
}
#
&request += {
- &Tmp-String-0 = 'foo'
- &Tmp-String-0 = 'bar'
- &Tmp-String-0 = 'baz'
+ &Filter-Id = 'foo'
+ &Filter-Id = 'bar'
+ &Filter-Id = 'baz'
- &Tmp-String-1 = 'GROUP ADMINISTRATORS'
- &Tmp-String-1 = 'GROUP STUDENTS'
- &Tmp-String-1 = 'GROUP PEONS'
+ &NAS-Port-Id = 'GROUP ADMINISTRATORS'
+ &NAS-Port-Id = 'GROUP STUDENTS'
+ &NAS-Port-Id = 'GROUP PEONS'
- &Tmp-String-2 = 'PEONS'
- &Tmp-String-2 = 'STUDENTS'
- &Tmp-String-2 = 'ADMINISTRATORS'
+ &Reply-Message = 'PEONS'
+ &Reply-Message = 'STUDENTS'
+ &Reply-Message = 'ADMINISTRATORS'
- &Tmp-String-3 = 'no'
- &Tmp-String-3 = 'no'
- &Tmp-String-3 = 'yes'
+ &Callback-Id = 'no'
+ &Callback-Id = 'no'
+ &Callback-Id = 'yes'
- &Tmp-Integer-0 = 1
- &Tmp-Integer-0 = 2
- &Tmp-Integer-0 = 5
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 5
}
&control += {
- &Tmp-String-0 = 'foo'
- &Tmp-String-0 = 'bar'
- &Tmp-String-0 = 'baz'
+ &Filter-Id = 'foo'
+ &Filter-Id = 'bar'
+ &Filter-Id = 'baz'
- &Tmp-String-1 = 'boink'
- &Tmp-String-1 = 'tard'
- &Tmp-String-1 = 'dink'
- &Tmp-String-1 = 'slink'
+ &NAS-Port-Id = 'boink'
+ &NAS-Port-Id = 'tard'
+ &NAS-Port-Id = 'dink'
+ &NAS-Port-Id = 'slink'
- &Tmp-Integer-0 = 01
- &Tmp-Integer-0 = 02
- &Tmp-Integer-0 = 05
- &Tmp-Integer-0 = 04
+ &NAS-Port = 01
+ &NAS-Port = 02
+ &NAS-Port = 05
+ &NAS-Port = 04
- &Tmp-Integer-1 = 10
- &Tmp-Integer-1 = 20
- &Tmp-Integer-1 = 30
+ &Port-Limit = 10
+ &Port-Limit = 20
+ &Port-Limit = 30
}
#
# Mmmm O(N^2)
#
-if (!(&Tmp-String-0[*] == &control.Tmp-String-0[*])) {
+if (!(&Filter-Id[*] == &control.Filter-Id[*])) {
test_fail
}
-if (&Tmp-String-0[*] == &control.Tmp-String-1[*]) {
+if (&Filter-Id[*] == &control.NAS-Port-Id[*]) {
test_fail
}
-if (&Tmp-String-1[*] == &control.Tmp-String-0[*]) {
+if (&NAS-Port-Id[*] == &control.Filter-Id[*]) {
test_fail
}
#
# Integer comparison and normalisation
#
-if (!(&Tmp-Integer-0 == &control.Tmp-Integer-0)) {
+if (!(&NAS-Port == &control.NAS-Port)) {
test_fail
}
#
-# if any value of request.Tmp-Integer-0 > any value of
-# request.Tmp-Integer-1 then evaluate to true
+# if any value of request.NAS-Port > any value of
+# request.Port-Limit then evaluate to true
#
-if (&Tmp-Integer-0[*] > &control.Tmp-Integer-1[*]) {
+if (&NAS-Port[*] > &control.Port-Limit[*]) {
test_fail
}
#
# Compiled regex comparisons
#
-if (&Tmp-String-1[*] !~ /PEONS$/) {
+if (&NAS-Port-Id[*] !~ /PEONS$/) {
test_fail
}
-if (&control.Tmp-String-1 =~ /PEONS$/) {
+if (&control.NAS-Port-Id =~ /PEONS$/) {
test_fail
}
-if (&control.Tmp-String-1 =~ /DINKS$/) {
+if (&control.NAS-Port-Id =~ /DINKS$/) {
test_fail
}
#
# Dynamic regex comparisons
#
-if (&Tmp-String-1[*] !~ /%{Tmp-String-2[0]}$/) {
+if (&NAS-Port-Id[*] !~ /%{Reply-Message[0]}$/) {
test_fail
}
-if (&Tmp-String-1 =~ /%{Tmp-String-2[1]}$/) {
+if (&NAS-Port-Id =~ /%{Reply-Message[1]}$/) {
test_fail
}
-if !(&Tmp-String-1 =~ /%{Tmp-String-2[2]}$/) {
+if !(&NAS-Port-Id =~ /%{Reply-Message[2]}$/) {
test_fail
}
-if (&Tmp-String-1 =~ /%{Tmp-String-2[#]}$/) {
+if (&NAS-Port-Id =~ /%{Reply-Message[#]}$/) {
test_fail
}
#
# XLAT virtual comparisons
#
-if (!(&control.Tmp-Integer-0[*] == %{control.Tmp-Integer-0[#]})) {
+if (!(&control.NAS-Port[*] == %{control.NAS-Port[#]})) {
test_fail
}
#
# Literal comparisons
#
-if (!(&control.Tmp-String-1[*] == 'boink')) {
+if (!(&control.NAS-Port-Id[*] == 'boink')) {
test_fail
}
-if (&control.Tmp-String-1[*] == 'foo') {
+if (&control.NAS-Port-Id[*] == 'foo') {
test_fail
}
-if (&Tmp-Integer-0[*] > 10) {
+if (&NAS-Port[*] > 10) {
test_fail
}
-if (!(&Tmp-Integer-0[*] < 10)) {
+if (!(&NAS-Port[*] < 10)) {
test_fail
}
# Check assignment of regex null-match
#
if (&control.Password.Cleartext =~ /hell(o)(.*)/) {
- &control.Tmp-String-1 := "%{2}"
+ &control.Filter-Id := "%{2}"
}
-if (!&control.Tmp-String-1) {
+if (!&control.Filter-Id) {
test_fail
}
-if (!(&control.Tmp-String-1 == "")) {
+if (!(&control.Filter-Id == "")) {
test_fail
}
# PRE: if
#
-&Tmp-Integer-0 := '123456789'
+string test_string
+string dummy_string
+uint32 test_integer
+
+&test_integer := '123456789'
# Non matching on attribute ref
-if !(&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{Tmp-String-0}/) {
+if !(&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{test_string}/) {
test_fail
}
# Matching on xlat expanded value
-if !("%{User-Name}" =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{Tmp-String-0}/) {
+if !("%{User-Name}" =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{test_string}/) {
test_fail
}
# Matching on attribute ref with capture groups
-if (&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{Tmp-String-0}/) {
+if (&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{test_string}/) {
# Test all the capture groups
&reply.User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
}
}
# Checking capture groups are cleared out correctly
-if (&User-Name =~ /^([0-9])_%{Tmp-String-0}/) {
+if (&User-Name =~ /^([0-9])_%{test_string}/) {
if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1_1')) {
test_fail
}
}
# Checking capture groups are cleared out correctly when there are no matches
-if (&User-Name =~ /^.%{Tmp-String-0}/) {
+if (&User-Name =~ /^.%{test_string}/) {
if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1')) {
test_fail
}
}
# uncompiled - ref - insensitive
-if !(&Calling-Station-Id =~ /:roamyroam%{Tmp-String-0}$/i) {
+if !(&Calling-Station-Id =~ /:roamyroam%{test_string}$/i) {
test_fail
}
# uncompiled - expansion - insensitive
-if !(&Calling-Station-Id =~ /:roamyroam%{Tmp-String-0}$/i) {
+if !(&Calling-Station-Id =~ /:roamyroam%{test_string}$/i) {
test_fail
}
# uncompiled - enum - ref - insensitive
-if !(&Service-Type =~ /^framed-user%{Tmp-String-0}$/i) {
+if !(&Service-Type =~ /^framed-user%{test_string}$/i) {
test_fail
}
# uncompiled - enum - expansion - insensitive
-if !("%{Service-Type}" =~ /^framed-user%{Tmp-String-0}$/i) {
+if !("%{Service-Type}" =~ /^framed-user%{test_string}$/i) {
test_fail
}
# uncompiled - enum - ref
-if (&Service-Type =~ /^framed-user%{Tmp-String-0}$/) {
+if (&Service-Type =~ /^framed-user%{test_string}$/) {
test_fail
}
# uncompiled - integer - ref
-if !(&Tmp-Integer-0 =~ /%{Tmp-Integer-0}/) {
+if !(&test_integer =~ /%{test_integer}/) {
test_fail
}
-&Tmp-String-0 := "foo\nbar"
+&test_string := "foo\nbar"
# uncompiled - ref - multiline
-if !(&Tmp-String-0 =~ /^foo$%{Tmp-String-8}/m) {
+if !(&test_string =~ /^foo$%{dummy_string}/m) {
test_fail
}
# uncompiled - ref - non-multiline
-if (&Tmp-String-0 =~ /^foo$%{Tmp-String-8}/) {
+if (&test_string =~ /^foo$%{dummy_string}/) {
test_fail
}
# uncompiled - ref - non-multiline
-if !(&Tmp-String-0 =~ /^foo\nbar%{Tmp-String-8}$/) {
+if !(&test_string =~ /^foo\nbar%{dummy_string}$/) {
test_fail
}
# uncompiled - ref - multiline
-if !(&Tmp-String-0 =~ /^bar%{Tmp-String-8}$/m) {
+if !(&test_string =~ /^bar%{dummy_string}$/m) {
test_fail
}
# uncompiled - ref - multiline - sensitive
-if (&Tmp-String-0 =~ /^BAR%{Tmp-String-8}$/m) {
+if (&test_string =~ /^BAR%{dummy_string}$/m) {
test_fail
}
# uncompiled - ref - multiline - insensitive
-if !(&Tmp-String-0 =~ /^BAR%{Tmp-String-8}$/mi) {
+if !(&test_string =~ /^BAR%{dummy_string}$/mi) {
test_fail
}
# uncompiled - ref - multiline - insensitive (flag order reversed)
-if !(&Tmp-String-0 =~ /^BAR%{Tmp-String-8}$/im) {
+if !(&test_string =~ /^BAR%{dummy_string}$/im) {
test_fail
}
# PRE: if
#
+string test_string
# Non matching on attribute ref
if !(&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
test_fail
}
-&Tmp-String-0 := "foo\nbar"
+&test_string := "foo\nbar"
# compiled - ref - multiline
-if !(&Tmp-String-0 =~ /^foo$/m) {
+if !(&test_string =~ /^foo$/m) {
test_fail
}
# compiled - ref - non-multiline
-if (&Tmp-String-0 =~ /^foo$/) {
+if (&test_string =~ /^foo$/) {
test_fail
}
# compiled - ref - non-multiline
# Not all POSIX implementations support the \n character classes
# so only run this test if the server was built with libpcre.
-if ((('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) && !(&Tmp-String-0 =~ /^foo\nbar$/)) {
+if ((('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) && !(&test_string =~ /^foo\nbar$/)) {
test_fail
}
# compiled - ref - multiline
-if !(&Tmp-String-0 =~ /^bar$/m) {
+if !(&test_string =~ /^bar$/m) {
test_fail
}
# compiled - ref - multiline - sensitive
-if (&Tmp-String-0 =~ /^BAR$/m) {
+if (&test_string =~ /^BAR$/m) {
test_fail
}
# compiled - ref - multiline - insensitive
-if !(&Tmp-String-0 =~ /^BAR$/mi) {
+if !(&test_string =~ /^BAR$/mi) {
test_fail
}
# compiled - ref - multiline - insensitive (flag order reversed)
-if !(&Tmp-String-0 =~ /^BAR$/im) {
+if !(&test_string =~ /^BAR$/im) {
test_fail
}
# PRE: if if-failed-xlat
#
+string result_string
+string dummy_string
+
if (('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) {
&request += {
- &Tmp-Integer-0 = '123456789'
- &Tmp-Integer-1 = 1
+ &NAS-Port = '123456789'
+ &Port-Limit = 1
}
# Check failure when no previous capture - full capture
&request -= &Module-Failure-Message[*]
# Check failure when no previous capture - numbered group
-if (%regex(%{Tmp-Integer-1})) {
+if (%regex(%{Port-Limit})) {
test_fail
}
&request -= &Module-Failure-Message[*]
# uncompiled - ref - named capture groups
-if (&User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])%{Tmp-String-1}/) {
- &Tmp-String-0 := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}"
- if (!(&Tmp-String-0 == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
+if (&User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])%{dummy_string}/) {
+ &result_string := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}"
+ if (!(&result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
test_fail
}
}
}
# Checking capture groups are cleared out correctly
-if (&User-Name =~ /^(?<one>[0-9])_%{Tmp-String-1}/) {
- &Tmp-String-0 := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)"
- if (!(&Tmp-String-0 == '1_1')) {
+if (&User-Name =~ /^(?<one>[0-9])_%{dummy_string}/) {
+ &result_string := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)"
+ if (!(&result_string == '1_1')) {
test_fail
}
}
}
# Checking capture groups are cleared out correctly when there are no matches
-if (&User-Name =~ /^.%{Tmp-String-1}/) {
- &Tmp-String-0 := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)"
- if (!(&Tmp-String-0 == '1')) {
+if (&User-Name =~ /^.%{dummy_string}/) {
+ &result_string := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)"
+ if (!(&result_string == '1')) {
test_fail
}
}
# compiled - ref - named capture groups
if (&User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
- &Tmp-String-0 := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}"
- if (!(&Tmp-String-0 == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
+ &result_string := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}"
+ if (!(&result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
test_fail
}
}
# compiled - xlat - named capture groups
if ('1_2_3_4_5_6_7' =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
- &Tmp-String-0 := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}"
- if (!(&Tmp-String-0 == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
+ &result_string := "%regex(seven)_%regex(six)_%regex(five)_%regex(four)_%regex(three)_%regex(two)_%regex(one)_%{0}"
+ if (!(&result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
test_fail
}
}
# compiled - ref - named capture groups (numeric indexes)
if (&User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
- &Tmp-String-0 := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
- if (!(&Tmp-String-0 == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
+ &result_string := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
+ if (!(&result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
test_fail
}
# compiled - ref - named capture groups (numeric indexes using expansion)
if (&User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
- &Tmp-Integer-0 := 0
- &Tmp-Integer-1 := 1
- &Tmp-Integer-2 := 2
- &Tmp-Integer-3 := 3
- &Tmp-Integer-4 := 4
- &Tmp-Integer-5 := 5
- &Tmp-Integer-6 := 6
- &Tmp-Integer-7 := 7
-
- &Tmp-String-0 := "%regex(%{Tmp-Integer-7})_%regex(%{Tmp-Integer-6})_%regex(%{Tmp-Integer-5})_%regex(%{Tmp-Integer-4})_%regex(%{Tmp-Integer-3})_%regex(%{Tmp-Integer-2})_%regex(%{Tmp-Integer-1})_%regex(%{Tmp-Integer-0})"
- if (!(&Tmp-String-0 == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
+ uint32 a
+ uint32 b
+ uint32 c
+ uint32 d
+ uint32 e
+ uint32 f
+ uint32 g
+ uint32 h
+ &a := 0
+ &b := 1
+ &c := 2
+ &d := 3
+ &e := 4
+ &f := 5
+ &g := 6
+ &h := 7
+
+ &result_string := "%regex(%{h})_%regex(%{g})_%regex(%{f})_%regex(%{e})_%regex(%{d})_%regex(%{c})_%regex(%{b})_%regex(%{a})"
+ if (!(&result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
test_fail
}
}
#
# They can't be modified or deleted.
#
+uint32 test_integer
+
&NAS-Port := 1812
#
#
# We can copy the immutable value. The copy is mutable.
#
-&Tmp-Integer-0 := &NAS-Port
-if !(&Tmp-Integer-0 == 1813) {
+&test_integer := &NAS-Port
+if !(&test_integer == 1813) {
test_fail
}
-&Tmp-Integer-0 += 1
-if !(&Tmp-Integer-0 == 1814) {
+&test_integer += 1
+if !(&test_integer == 1814) {
test_fail
}
#
# PRE: if
#
-
-&request += {
- # Dotted Quad
- &Tmp-IP-Address-0 = 127.0.0.1
-
- # Dotted Quad with prefix
- &Tmp-IP-Address-1 = 127.0.0.2/32
-
- # Hex (0x)
- &Tmp-IP-Address-2 = 0x7f000003
-
- # Decimal
- &Tmp-IP-Address-3 = 2130706436
-}
+ipaddr result_ipaddr
if (!(&NAS-IP-Address == 127.0.0.1)) {
test_fail
}
-if (!(&Tmp-IP-Address-0 == 127.0.0.1)) {
+# Dotted Quad
+&result_ipaddr := 127.0.0.1
+if (!(&result_ipaddr == 127.0.0.1)) {
test_fail
}
-if (!(&Tmp-IP-Address-1 == 127.0.0.2)) {
+# Dotted Quad with prefix
+&result_ipaddr := 127.0.0.2/32
+if (!(&result_ipaddr == 127.0.0.2)) {
test_fail
}
-if (!(&Tmp-IP-Address-2 == 127.0.0.3)) {
+# Hex (0x)
+&result_ipaddr := 0x7f000003
+if (!(&result_ipaddr == 127.0.0.3)) {
test_fail
}
-if (!(&Tmp-IP-Address-3 == 127.0.0.4)) {
+# Decimal
+&result_ipaddr := 2130706436
+if (!(&result_ipaddr == 127.0.0.4)) {
test_fail
}
#
# PRE: if
#
-&control += {
- &Tmp-Cast-IPv4Prefix = 198.51.100.255/16
- &Tmp-Cast-IPv6Prefix = ::198.51.100.255/112
- &Framed-IP-Address = 198.51.0.1
-}
+ipv4prefix test_ipv4prefix
+ipv6prefix test_ipv6prefix
+
+&test_ipv4prefix := 198.51.100.255/16
+&test_ipv6prefix := ::198.51.100.255/112
+&Framed-IP-Address := 198.51.0.1
-if (!(&control.Tmp-Cast-IPv6Prefix == '::198.51.0.0/112')) {
+if (!(&test_ipv6prefix == '::198.51.0.0/112')) {
test_fail
}
-if (!(&control.Tmp-Cast-IPv4Prefix == '198.51.0.0/16')) {
+if (!(&test_ipv4prefix == '198.51.0.0/16')) {
test_fail
}
-if (!(&control.Tmp-Cast-IPv6Prefix == ::198.51.0.0/112)) {
+if (!(&test_ipv6prefix == ::198.51.0.0/112)) {
test_fail
}
-if (!(&control.Tmp-Cast-IPv4Prefix == 198.51.0.0/16)) {
+if (!(&test_ipv4prefix == 198.51.0.0/16)) {
test_fail
}
-if (!(&control.Tmp-Cast-IPv4Prefix < 198.0.0.0/8)) {
+if (!(&test_ipv4prefix < 198.0.0.0/8)) {
test_fail
}
-if (!(&control.Framed-IP-Address < 198.51.0.0/16)) {
+if (!(&Framed-IP-Address < 198.51.0.0/16)) {
test_fail
}
#
# PRE: if concat
#
+string result_string
+
&control -= &Password[*]
&control += {
&User-Name = &request.User-Name
&User-Password = &request.User-Password
- &Tmp-String-0 = "ab c"
- &Tmp-String-0 = "de fg"
- &Tmp-Integer-0 = 123
+ &Filter-Id = "ab c"
+ &Filter-Id = "de fg"
+ &NAS-Port = 123
}
-&request.Tmp-IP-Address-0 := 192.168.1.254
+&request.Framed-IP-Address := 192.168.1.254
debug_control
debug_request
#
# @todo - fix this...
#
-&control.Tmp-String-1 := %concat(%join(%{control.[*]}, %{request.Tmp-IP-Address-0}), '. ')
+&result_string := %concat(%join(%{control.[*]}, %{request.Framed-IP-Address}), '. ')
-if (!(&control.Tmp-String-1 == "bob. hello. ab c. de fg. 123. 192.168.1.254")) {
+if (!(&result_string == "bob. hello. ab c. de fg. 123. 192.168.1.254")) {
test_fail
}
-&control.Tmp-String-2 := %concat(%join(%{control.Tmp-String-0[*]}, %{control.Tmp-Integer-0}), ',')
-if (!(&control.Tmp-String-2 == "ab c,de fg,123")) {
+&result_string := %concat(%join(%{control.Filter-Id[*]}, %{control.NAS-Port}), ',')
+if (!(&result_string == "ab c,de fg,123")) {
test_fail
}
#
# PRE: hex
#
-&request += {
- &Tmp-String-0 = '\
+string test_string
+octets test_octets
+ipaddr test_ipaddr
+uint32 test_integer
+ifid test_ifid
+ipv6addr test_ipv6addr
+ipv6prefix test_ipv6prefix
+byte test_byte
+uint16 test_short
+ether test_ether
+uint64 test_int64
+ipv4prefix test_ipv4prefix
+uint32 result_int
+
+&test_string := '\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
- &Tmp-String-2 = '9870'
- &Tmp-Octets-0 = 0x39383731
- &Tmp-IP-Address-0 = 57.56.55.50
- &Tmp-Integer-0 = 959985460
- &Tmp-Cast-IfId = '0000:0000:3938:3737'
- &Tmp-Cast-IPv6Addr = '::3938:3738'
- &Tmp-Cast-IPv6Prefix = '::3938:3739/128'
- &Tmp-Cast-Byte = 58
- &Tmp-Cast-Short = 14139
- &Tmp-Cast-Ether = 00:00:39:38:37:3c
- &Tmp-Cast-Integer64 = 1152921505566832445
- &Tmp-Cast-IPv4Prefix = 57.56.55.62/32
-}
-if (!(%length(%{Tmp-String-0}) == 260)) {
+if (!(%length(%{test_string}) == 260)) {
test_fail
}
-&request += {
- &Tmp-uint64-0 = %length(%{Tmp-String-2}) # Tmp-Integer-0 is defined and used below for Tmp-Integer-4
- &Tmp-Integer-1 = %length(%{Tmp-Octets-0})
- &Tmp-Integer-2 = %length(%{Tmp-IP-Address-0})
- &Tmp-Integer-3 = %length('hello, world')
- &Tmp-Integer-4 = %length(%{Tmp-Integer-0})
- &Tmp-Integer-6 = %length(%{Tmp-Cast-Ifid})
- &Tmp-Integer-7 = %length(%{Tmp-Cast-IPv6Addr})
- &Tmp-Integer-8 = %length(%{Tmp-Cast-IPv6Prefix})
- &Tmp-Integer-9 = %length(%{Tmp-Cast-Byte})
-}
+&test_string := '9870'
+&test_octets := 0x39383731
+&test_ipaddr := 57.56.55.50
+&test_integer := 959985460
+&test_ifid := '0000:0000:3938:3737'
+&test_ipv6addr := '::3938:3738'
+&test_ipv6prefix = '::3938:3739/128'
+&test_byte := 58
+&test_short := 14139
+&test_ether := 00:00:39:38:37:3c
+&test_int64 := 1152921505566832445
+&test_ipv4prefix := 57.56.55.62/32
# String - bin 0x39383730
-if (!(&Tmp-uint64-0 == 4)) {
+&result_int := %length(%{test_string})
+if (!(&result_int == 4)) {
test_fail
}
# Octets - bin 0x39383731
-if (!(&Tmp-Integer-1 == 4)) {
+&result_int := %length(%{test_octets})
+if (!(&result_int == 4)) {
test_fail
}
# IP Address - bin 0x39383732
-if (!(&Tmp-Integer-2 == 4)) {
+&result_int := %length(%{test_ipaddr})
+if (!(&result_int == 4)) {
test_fail
}
# String - "hello, world"
-if (!(&Tmp-Integer-3 == 12)) {
+&result_int := %length('hello, world')
+if (!(&result_int == 12)) {
test_fail
}
# Integer - bin 0x39383734
-if (!(&Tmp-Integer-4 == 4)) {
+&result_int := %length(%{test_integer})
+if (!(&result_int == 4)) {
test_fail
}
# ifid - bin 0x0000000039383737
-if (!(&Tmp-Integer-6 == 8)) {
+&result_int := %length(%{test_ifid})
+if (!(&result_int == 8)) {
test_fail
}
# ipv6addr - bin 0x00000000000000000000000039383738
-if (!(&Tmp-Integer-7 == 16)) {
+&result_int := %length(%{test_ipv6addr})
+if (!(&result_int == 16)) {
test_fail
}
# ipv6addrprefix - bin 0x8000000000000000000000000039383739
-if (!(&Tmp-Integer-8 == 17)) {
+&result_int := %length(%{test_ipv6prefix})
+if (!(&result_int == 17)) {
test_fail
}
# byte - bin 0x3a
-if (!(&Tmp-Integer-9 == 1)) {
+&result_int := %length(%{test_byte})
+if (!(&result_int == 1)) {
test_fail
}
-&Tmp-Integer-0 := %length(%{Tmp-Cast-Short})
-&Tmp-Integer-1 := %length(%{Tmp-Cast-Ether})
-&Tmp-Integer-2 := %length(%{Tmp-Cast-Integer64})
-&Tmp-Integer-3 := %length(%{Tmp-Cast-IPv4Prefix})
-
# short - bin 0x373b
-if (!(&Tmp-Integer-0 == 2)) {
+&result_int := %length(%{test_short})
+if (!(&result_int == 2)) {
test_fail
}
# ethernet - bin 0x00003938373c
-if (!(&Tmp-Integer-1 == 6)) {
+&result_int := %length(%{test_ether})
+if (!(&result_int == 6)) {
test_fail
}
# integer64 - bin 0x100000003938373d
-if (!(&Tmp-Integer-2 == 8)) {
+&result_int := %length(%{test_int64})
+if (!(&result_int == 8)) {
test_fail
}
# ipv4prefix - bin 0x203938373e
-if (!(&Tmp-Integer-3 == 5)) {
+&result_int := %length(%{test_ipv4prefix})
+if (!(&result_int == 5)) {
test_fail
}
#
# Should distribute load between the modules.
#
-&request += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-1 = 0
+uint32 count1
+uint32 count2
+
+&count1 := 0
+&count2 := 0
- &Tmp-Integer-2 = 0 # 0
- &Tmp-Integer-2 = 1
- &Tmp-Integer-2 = 2
- &Tmp-Integer-2 = 3
- &Tmp-Integer-2 = 4
- &Tmp-Integer-2 = 5
- &Tmp-Integer-2 = 6
- &Tmp-Integer-2 = 7
- &Tmp-Integer-2 = 8
- &Tmp-Integer-2 = 9 # 10
- &Tmp-Integer-2 = 0
- &Tmp-Integer-2 = 1
- &Tmp-Integer-2 = 2
- &Tmp-Integer-2 = 3
- &Tmp-Integer-2 = 4
- &Tmp-Integer-2 = 5
- &Tmp-Integer-2 = 6
- &Tmp-Integer-2 = 7
- &Tmp-Integer-2 = 8
- &Tmp-Integer-2 = 9 # 20
- &Tmp-Integer-2 = 0
- &Tmp-Integer-2 = 1
- &Tmp-Integer-2 = 2
- &Tmp-Integer-2 = 3
- &Tmp-Integer-2 = 4
- &Tmp-Integer-2 = 5
- &Tmp-Integer-2 = 6
- &Tmp-Integer-2 = 7
- &Tmp-Integer-2 = 8
- &Tmp-Integer-2 = 9 # 30
- &Tmp-Integer-2 = 0
- &Tmp-Integer-2 = 1
- &Tmp-Integer-2 = 2
- &Tmp-Integer-2 = 3
- &Tmp-Integer-2 = 4
- &Tmp-Integer-2 = 5
- &Tmp-Integer-2 = 6
- &Tmp-Integer-2 = 7
- &Tmp-Integer-2 = 8
- &Tmp-Integer-2 = 9 # 40
- &Tmp-Integer-2 = 0
- &Tmp-Integer-2 = 1
- &Tmp-Integer-2 = 2
- &Tmp-Integer-2 = 3
- &Tmp-Integer-2 = 4
- &Tmp-Integer-2 = 5
- &Tmp-Integer-2 = 6
- &Tmp-Integer-2 = 7
- &Tmp-Integer-2 = 8
- &Tmp-Integer-2 = 9 # 49
+&request += {
+ &NAS-Port = 0 # 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9 # 10
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9 # 20
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9 # 30
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9 # 40
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9 # 49
}
#
# Loop 0..9
#
-foreach &Tmp-Integer-2 {
+foreach &NAS-Port {
load-balance {
group {
- &Tmp-Integer-0 += 1
+ &count1 += 1
&request += {
- &Tmp-String-0 = "Picked group 1 - %{Tmp-Integer-0} time(s)"
+ &Reply-Message = "Picked group 1 - %{count1} time(s)"
}
ok
}
group {
- &Tmp-Integer-1 += 1
+ &count2 += 1
&request += {
- &Tmp-String-1 = "Picked group 2 %{Tmp-Integer-1} Time(s)"
+ &Reply-Message = "Picked group 2 %{count2} Time(s)"
}
ok
}
# The chances of one group being used over another 50 times by random occurrence
# is quite small, and if this happens repeatedly, it's likely there's a bug in
# the load-balance code or random number generator.
-if ((&Tmp-Integer-0 == 0) || (&Tmp-Integer-1 == 0)) {
+if ((&count1 == 0) || (&count2 == 0)) {
test_fail
}
-if !(&Tmp-Integer-0 + &Tmp-Integer-1 == 50) {
+if !(&count1 + &count2 == 50) {
test_fail
}
#
# PRE: edit
#
-&request += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-1 = 1
-}
+uint32 test_integer1
+uint32 test_integer2
+
+&test_integer1 := 0
+&test_integer2 := 1
#
# (true && true) --> true
#
# But if it's false, then we have an issue.
#
-if !((&Tmp-Integer-0 == 0) && (&Tmp-Integer-1 == 1)) {
+if !((&test_integer1 == 0) && (&test_integer2 == 1)) {
test_fail
}
#
# false && true --> false
#
-if ((&Tmp-Integer-0 == 1) && (&Tmp-Integer-1 == 1)) {
+if ((&test_integer1 == 1) && (&test_integer2 == 1)) {
test_fail
}
#
# true && false -> false
#
-if ((&Tmp-Integer-0 == 0) && (&Tmp-Integer-1 == 0)) {
+if ((&test_integer1 == 0) && (&test_integer2 == 0)) {
test_fail
}
-&control.Tmp-String-0 := { "bob", "oof" }
+&control.Filter-Id := { "bob", "oof" }
-if ((&control.Tmp-String-0[0] == 'bob') && (&control.Tmp-String-0[1] == 'oof')) {
+if ((&control.Filter-Id[0] == 'bob') && (&control.Filter-Id[1] == 'oof')) {
# OK
} else {
test_fail
#
# PRE: edit
#
-&request += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-1 = 1
-}
+uint32 test_integer1
+uint32 test_integer2
+
+&test_integer1 := 0
+&test_integer2 := 1
-if !((&Tmp-Integer-0 == 1) || (&Tmp-Integer-1 == 1)) {
+if !((&test_integer1 == 1) || (&test_integer2 == 1)) {
test_fail
}
-if !((&Tmp-Integer-1 == 1) || (&Tmp-Integer-0 == 1)) {
+if !((&test_integer2 == 1) || (&test_integer1 == 1)) {
test_fail
}
#
# Neither of these exists, so the resulting string should be empty
#
-&Tmp-String-0 := "%{&Tmp-String-1 || &Tmp-String-1}"
+&Filter-Id := "%{&NAS-Port-Id || &NAS-Port-Id}"
-if !(&Tmp-String-0 == '') {
+if !(&Filter-Id == '') {
test_fail
}
# PRE: map
#
-&control.Tmp-String-0 := "fail"
+&control.Filter-Id := "fail"
map csv &User-Name {
- &control.Tmp-String-0 ^= 'field3'
+ &control.Filter-Id ^= 'field3'
}
-if (!(&control.Tmp-String-0[0] == 'success')) {
+if (!(&control.Filter-Id[0] == 'success')) {
test_fail
}
-if (!(&control.Tmp-String-0[1] == "fail")) {
+if (!(&control.Filter-Id[1] == "fail")) {
test_fail
}
-if (!(%{control.Tmp-String-0[#]} == 2)) {
+if (!(%{control.Filter-Id[#]} == 2)) {
test_fail
}
# Test the map xlat
#
&request += {
- &Tmp-String-0 = '&control.Tmp-String-0 := \'testing123\''
- &Tmp-String-1 = "request.Vendor-Specific.Nokia-SR.MSAP-Interface = 'UNICAST_7360OLT3'"
- &Tmp-String-1 = "request.Vendor-Specific.Nokia-SR.MSAP-Interface += 'UNICAST_7360OLT4'"
+ &Filter-Id = '&control.Filter-Id := \'testing123\''
+ &NAS-Port-Id = "request.Vendor-Specific.Nokia-SR.MSAP-Interface = 'UNICAST_7360OLT3'"
+ &NAS-Port-Id = "request.Vendor-Specific.Nokia-SR.MSAP-Interface += 'UNICAST_7360OLT4'"
}
-if (!("%map(%{Tmp-String-0})" == 1)) {
+if (!("%map(%{Filter-Id})" == 1)) {
test_fail
}
-if (!(&control.Tmp-String-0 == 'testing123')) {
+if (!(&control.Filter-Id == 'testing123')) {
test_fail
}
-foreach &Tmp-String-1[*] {
+foreach &NAS-Port-Id[*] {
if (!("%map(%{Foreach-Variable-0})" == 1)) {
test_fail
}
#
# Test the map xlat
#
-&Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-1 = 'testing123'"
+&Filter-Id := "request.Tmp-Group-0.User-Name = 'testing123'"
-if (!("%map(%{Tmp-String-0})" == 1)) {
+if (!("%map(%{Filter-Id})" == 1)) {
test_fail
}
#
# Test the map xlat
#
-&Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-0 := 'testing123'"
+&Filter-Id := "request.Tmp-Group-0.Filter-Id := 'testing123'"
-if (!(%map("%{Tmp-String-0}") == 1)) {
+if (!(%map("%{Filter-Id}") == 1)) {
test_fail
}
-if (!(%map("%{Tmp-String-0}") == 1)) {
+if (!(%map("%{Filter-Id}") == 1)) {
test_fail
}
-if (!(%map("request.Tmp-Group-0.Tmp-String-1 := 'testing000'") == 1)) {
+if (!(%map("request.Tmp-Group-0.User-Name := 'testing000'") == 1)) {
test_fail
}
-if (!&Tmp-Group-0[0].Tmp-String-0 || (!(&Tmp-Group-0[0].Tmp-String-0 == 'testing123'))) {
+if (!&Tmp-Group-0[0].Filter-Id || (!(&Tmp-Group-0[0].Filter-Id == 'testing123'))) {
test_fail
}
-if (!&Tmp-Group-0[0].Tmp-String-1 || (!(&Tmp-Group-0[0].Tmp-String-1 == 'testing000'))) {
+if (!&Tmp-Group-0[0].User-Name || (!(&Tmp-Group-0[0].User-Name == 'testing000'))) {
test_fail
}
#
# Test the map xlat
#
-&Tmp-String-0 := "IA-PD.IAID = 11"
+string test_string
-if (!("%map(%{Tmp-String-0})" == 1)) {
+&test_string := "IA-PD.IAID = 11"
+
+if (!("%map(%{test_string})" == 1)) {
test_fail
}
#
# PRE: if
#
-&request += {
- &Tmp-String-0 = "This is a string\n"
- &Tmp-Octets-0 = 0x000504030201
- &Tmp-String-1 = "what do ya want for nothing?"
- &Tmp-String-2 = "Jefe"
- &Tmp-String-3 = ""
-}
-
+string test_string
+string dummy_string
+octets test_octets
+octets result_octets
-&request += {
- &Tmp-Octets-1 = %md4("This is a string\n")
- &Tmp-Octets-2 = %md4("%{Tmp-String-0}")
- &Tmp-Octets-3 = %md4("%{request.Tmp-String-0}")
- &Tmp-Octets-4 = %md4("%{request.Tmp-Octets-0}")
- &Tmp-Octets-5 = %md4("%{Tmp-String-9}")
-}
+&test_string := "This is a string\n"
+&test_octets := 0x000504030201
#
# Put "This is a string" into a file and call "md4sum" on it.
# You should get this string.
#
-if (!(&Tmp-Octets-1 == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
- test_fail
-}
-
-if (!(&Tmp-Octets-2 == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
+&result_octets := %md4("This is a string\n")
+if (!(&result_octets == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
test_fail
}
-if (!(&Tmp-Octets-3 == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
+&result_octets := %md4("%{test_string}")
+if (!(&result_octets == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
test_fail
}
#
-# MD5 should also be able to cope with references to octet attributes
+# MD4 should also be able to cope with references to octet attributes
#
-if (!(&Tmp-Octets-4 == 0xac3ed17b3cf19ec38352ec534a932fc6)) {
+&result_octets := %md4("%{test_octets}")
+if (!(&result_octets == 0xac3ed17b3cf19ec38352ec534a932fc6)) {
test_fail
}
#
-# MD5 of null string is d41d8cd98f00b204e9800998ecf8427e
+# MD4 of null string is d41d8cd98f00b204e9800998ecf8427e
#
-if (!(&Tmp-Octets-5 == 0x31d6cfe0d16ae931b73c59d7e0c089c0)) {
+&result_octets := %md4("%{dummy_string}")
+if (!(&result_octets == 0x31d6cfe0d16ae931b73c59d7e0c089c0)) {
test_fail
}
#
# PRE: if
#
-&request += {
- &Tmp-String-0 = "This is a string\n"
- &Tmp-Octets-0 = 0x000504030201
- &Tmp-String-1 = "what do ya want for nothing?"
- &Tmp-String-2 = "Jefe"
- &Tmp-String-3 = ""
-}
-
+string test_string
+string dummy_string
+string test_hmac_key
+string test_hmac_data
+octets test_octets
+octets result_octets
-&request += {
- &Tmp-Octets-1 = %md5("This is a string\n")
- &Tmp-Octets-2 = %md5("%{Tmp-String-0}")
- &Tmp-Octets-3 = %md5("%{request.Tmp-String-0}")
- &Tmp-Octets-4 = %md5("%{request.Tmp-Octets-0}")
- &Tmp-Octets-5 = %md5("%{Tmp-String-9}")
- &Tmp-Octets-6 = %hmacmd5("%{Tmp-String-1}", "%{Tmp-String-2}")
- &Tmp-Octets-7 = %hmacmd5("%{Tmp-String-3}", "%{Tmp-String-3}")
-}
+&test_string := "This is a string\n"
+&test_octets := 0x000504030201
+&test_hmac_key := "what do ya want for nothing?"
+&test_hmac_data := "Jefe"
#
# Put "This is a string" into a file and call "md5sum" on it.
# You should get this string.
#
-if (!(&Tmp-Octets-1 == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
- test_fail
-}
-
-if (!(&Tmp-Octets-2 == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
+&result_octets := %md5("This is a string\n")
+if (!(&result_octets == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
test_fail
}
-if (!(&Tmp-Octets-3 == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
+&result_octets := %md5("%{test_string}")
+if (!(&result_octets == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
test_fail
}
#
# MD5 should also be able to cope with references to octet attributes
#
-if (!(&Tmp-Octets-4 == 0xc1e7fa505b2fc1fd0da6cac3db6f6f44)) {
+&result_octets := %md5("%{test_octets}")
+if (!(&result_octets == 0xc1e7fa505b2fc1fd0da6cac3db6f6f44)) {
test_fail
}
#
# MD5 of null string is d41d8cd98f00b204e9800998ecf8427e
#
-if (!(&Tmp-Octets-5 == 0xd41d8cd98f00b204e9800998ecf8427e)) {
+&result_octets := %md5("%{dummy_string}")
+if (!(&result_octets == 0xd41d8cd98f00b204e9800998ecf8427e)) {
test_fail
}
#
# MD5 HMAC with attribute references
#
-if (!(&Tmp-Octets-6 == 0x750c783e6ab0b503eaa86e310a5db738)) {
+&result_octets := %hmacmd5("%{test_hmac_key}", "%{test_hmac_data}")
+if (!(&result_octets == 0x750c783e6ab0b503eaa86e310a5db738)) {
test_fail
}
#
# MD5 HMAC with empty key and data
#
-if (!(&Tmp-Octets-7 == 0x74e6f7298a9c2d168935f58c001bad88)) {
+&dummy_string := ''
+&result_octets := %hmacmd5("%{dummy_string}", "%{dummy_string}")
+if (!(&result_octets == 0x74e6f7298a9c2d168935f58c001bad88)) {
test_fail
}
#
# PRE: md5
#
+string test_string
+octets result_octets
-&Tmp-String-1 := "hello"
+&test_string := "hello"
#
# MD5 HMAC with missing key should fail
#
-&Tmp-Octets-1 := %hmacmd5(%{Tmp-String-1}, )
-if &Tmp-Octets-1 {
+&result_octets := %hmacmd5(%{test_string}, )
+if &result_octets {
test_fail
}
success
#
# PRE: if
#
+string result_string
+octets result_octets
#
# over-write the existing User-Name
&Vendor-Specific.Microsoft.CHAP-Response = 0x00010000000000000000000000000000000000000000000000008860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f
}
-&request += {
- &Tmp-Octets-0 = %mschap(Challenge)
- &Tmp-Octets-1 = %mschap(NT-Response)
- &Tmp-String-0 = %mschap(NT-Domain)
- &Tmp-String-1 = %mschap(User-Name)
-}
-
-if !(&Tmp-Octets-0 == 0xe96e4fff2955c4f1) {
+&result_octets := %mschap(Challenge)
+if !(&result_octets == 0xe96e4fff2955c4f1) {
test_fail
}
-if !(&Tmp-Octets-1 == 0x8860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f) {
+&result_octets := %mschap(NT-Response)
+if !(&result_octets == 0x8860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f) {
test_fail
}
-if !(&Tmp-String-0 == 'EXAMPLE') {
+&result_string := %mschap(NT-Domain)
+if !(&result_string == 'EXAMPLE') {
test_fail
}
-if !(&Tmp-String-1 == 'bob') {
+&result_string := %mschap(User-Name)
+if !(&result_string == 'bob') {
test_fail
}
&request.Vendor-Specific.Microsoft.CHAP-Response := 0x00006937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db158860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f
-&Tmp-Octets-0 := %mschap(LM-Response)
+&result_octets := %mschap(LM-Response)
-if !(&Tmp-Octets-0 == 0x6937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db15) {
+if !(&result_octets == 0x6937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db15) {
test_fail
}
# Hashing
-&Tmp-Octets-0 := %mschap(NT-Hash, 'testing_123')
-&Tmp-Octets-1 := %mschap(LM-Hash, 'testing_123')
-
-if !(&Tmp-Octets-0 == 0xfa782604f85eb3564f555648341b53e4) {
+&result_octets := %mschap(NT-Hash, 'testing_123')
+if !(&result_octets == 0xfa782604f85eb3564f555648341b53e4) {
test_fail
}
-if !(&Tmp-Octets-1 == 0x2d5545077d7b7d2ae4343f96ab15c596) {
+&result_octets := %mschap(LM-Hash, 'testing_123')
+if !(&result_octets == 0x2d5545077d7b7d2ae4343f96ab15c596) {
test_fail
}
&Vendor-Specific.Microsoft.CHAP-Challenge := 0x04408dc2a98dae1ce351dfc53f57d08e
&Vendor-Specific.Microsoft.CHAP2-Response := 0x00010e93cfbfcef8d5b6af42d2b2ca5b43180000000000000000bc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b200
-&Tmp-Octets-0 := %mschap(Challenge)
-&Tmp-Octets-1 := %mschap(NT-Response)
-
-if !(&Tmp-Octets-0 == 0xad18b6b8e1478b4c) {
+&result_octets := %mschap(Challenge)
+if !(&result_octets == 0xad18b6b8e1478b4c) {
test_fail
}
-if !(&Tmp-Octets-1 == 0xbc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b2) {
+&result_octets := %mschap(NT-Response)
+if !(&result_octets == 0xbc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b2) {
test_fail
}
# Invalid
&Vendor-Specific.Microsoft.CHAP-Challenge := 0xf0eac4151d5346662ba8c5e428
-&Tmp-String-0 := %mschap(Challenge)
+&result_string := %mschap(Challenge)
-if (&Tmp-String-0) {
+if (&result_string) {
test_fail
}
test_fail
}
-success
\ No newline at end of file
+success
#
# PRE: expr
#
+uint32 result_integer
#
# Calculations based on month and year are not consistent due to
# different numbers of days involved. Check hour / day / week
#
-&Tmp-Integer-0 := "%{%nexttime(2h) - %nexttime(1h)}"
+&result_integer := "%{%nexttime(2h) - %nexttime(1h)}"
# We have a fudge factor of 1 second either way
-if ((&Tmp-Integer-0 < 3599) || (&Tmp-Integer-0 > 3601)) {
+if ((&result_integer < 3599) || (&result_integer > 3601)) {
test_fail
}
#
# Day
#
-&Tmp-Integer-0 := "%{%nexttime(3d) - %nexttime(1d)}"
-if ((&Tmp-Integer-0 < 172799) || (&Tmp-Integer-0 > 172801)) {
+&result_integer := "%{%nexttime(3d) - %nexttime(1d)}"
+if ((&result_integer < 172799) || (&result_integer > 172801)) {
test_fail
}
#
# Week
#
-&Tmp-Integer-0 := "%{%nexttime(4w) - %nexttime(2w)}"
-if ((&Tmp-Integer-0 < 1209599) || (&Tmp-Integer-0 > 1209601)) {
+&result_integer := "%{%nexttime(4w) - %nexttime(2w)}"
+if ((&result_integer < 1209599) || (&result_integer > 1209601)) {
test_fail
}
#
# PRE: if
#
+string dummy_string
#
# This doesn't exist, so the condition shouldn't match.
#
-if (&Tmp-String-0 == "foo") {
+if (&dummy_string == "foo") {
test_fail
}
else {
#
# Since the middle part doesn't match, "NOT" the middle part SHOULD match.
#
-if (!(&Tmp-String-0 == "foo")) {
+if (!(&dummy_string == "foo")) {
ok
}
else {
#
# PRE: if
#
+octets result_octets
+
&request += {
&Framed-IP-Address = 127.0.0.1
&NAS-Port = 2112
}
-&Tmp-Octets-0 := (octets) &Framed-IP-Address + (octets) &NAS-Port + (octets) &NAS-IP-Address
+&result_octets := (octets) &Framed-IP-Address + (octets) &NAS-Port + (octets) &NAS-IP-Address
-if (!(&Tmp-Octets-0 == 0x7f000001000008407f000002)) {
+if (!(&result_octets == 0x7f000001000008407f000002)) {
test_fail
}
#
# With octet addition, we don't need %pack() any more!
#
-&Tmp-Octets-0 := (octets) &Framed-IP-Address + (octets) &NAS-Port + (octets) &NAS-IP-Address
+&result_octets := (octets) &Framed-IP-Address + (octets) &NAS-Port + (octets) &NAS-IP-Address
-if (!(&Tmp-Octets-0 == 0x7f000001000008407f000002)) {
+if (!(&result_octets == 0x7f000001000008407f000002)) {
test_fail
}
#
# PRE: if return
#
+string test_string
-&Tmp-String-0 = "test"
+&test_string = "test"
#
# rpad tests
#
-if (!(%rpad(%{Tmp-String-0}, 7) == "test ")) {
+if (!(%rpad(%{test_string}, 7) == "test ")) {
test_fail
}
-if (!(%rpad(%{Tmp-String-0}, 2) == "test")) {
+if (!(%rpad(%{test_string}, 2) == "test")) {
test_fail
}
-if (!(%rpad(%{Tmp-String-0}, 7, 'x') == "testxxx")) {
+if (!(%rpad(%{test_string}, 7, 'x') == "testxxx")) {
test_fail
}
-if (!(%rpad(%{Tmp-String-0}, 7, 'xy') == "testxyx")) {
+if (!(%rpad(%{test_string}, 7, 'xy') == "testxyx")) {
test_fail
}
#
# lpad tests
#
-if (!(%lpad(%{Tmp-String-0}, 7) == " test")) {
+if (!(%lpad(%{test_string}, 7) == " test")) {
test_fail
}
-if (!(%lpad(%{Tmp-String-0}, 2) == "test")) {
+if (!(%lpad(%{test_string}, 2) == "test")) {
test_fail
}
-if (!(%lpad(%{Tmp-String-0}, 7, 'x') == "xxxtest")) {
+if (!(%lpad(%{test_string}, 7, 'x') == "xxxtest")) {
test_fail
}
-if (!(%lpad(%{Tmp-String-0}, 7, 'xy') == "xyxtest")) {
+if (!(%lpad(%{test_string}, 7, 'xy') == "xyxtest")) {
test_fail
}
#
# PRE: update if
#
+string result_string
&request -= &Packet-Type[*]
&Tmp-Group-0 += {
- &Tmp-String-0 = "This is a string"
- &Tmp-String-0 = "This is another one"
- &Tmp-Octets-0 = 0x000504030201
- &Tmp-Integer-0 = 7331
+ &Filter-Id = "This is a string"
+ &Filter-Id = "This is another one"
+ &Class = 0x000504030201
+ &NAS-Port = 7331
}
#
#
#&pairs := %cast('string', %{Tmp-Group-0.[*]})
-&request += {
- &Tmp-String-1 = "%concat(%pairs(Tmp-Group-0.[*]), ', ')"
- &Tmp-String-2 = "%pairs(Tmp-Group-0.Tmp-String-0)"
- &Tmp-String-3 = "%concat(%pairs(Tmp-Group-0.Tmp-String-0[*]), ', ')"
- &Tmp-String-4 = "%concat(%pairs(control.[*]), ', ')"
- &Tmp-String-5 = "%pairs(control.User-Name)"
- &Tmp-String-6 = "%pairs(request.Tmp-Group-0)"
-}
-
-if !(&Tmp-String-1 == 'Tmp-String-0 = "This is a string", Tmp-String-0 = "This is another one", Tmp-Octets-0 = 0x000504030201, Tmp-Integer-0 = 7331') {
+&result_string := "%concat(%pairs(Tmp-Group-0.[*]), ', ')"
+if !(&result_string == 'Filter-Id = "This is a string", Filter-Id = "This is another one", Class = 0x000504030201, NAS-Port = 7331') {
test_fail
}
-if !(&Tmp-String-2 == 'Tmp-String-0 = "This is a string"') {
+&result_string := "%pairs(Tmp-Group-0.Filter-Id)"
+if !(&result_string == 'Filter-Id = "This is a string"') {
test_fail
}
-if !(&Tmp-String-3 == 'Tmp-String-0 = "This is a string", Tmp-String-0 = "This is another one"') {
+&result_string := "%concat(%pairs(Tmp-Group-0.Filter-Id[*]), ', ')"
+if !(&result_string == 'Filter-Id = "This is a string", Filter-Id = "This is another one"') {
test_fail
}
#
# Must be nested
#
-if !(&Tmp-String-4 == 'Password = { Cleartext = "hello" }') {
+&result_string := "%concat(%pairs(control.[*]), ', ')"
+if !(&result_string == 'Password = { Cleartext = "hello" }') {
test_fail
}
-if (!(&Tmp-String-5 == '')) {
+&result_string := "%pairs(control.User-Name)"
+if (!(&result_string == '')) {
test_fail
}
-if !(&Tmp-String-6 == 'Tmp-Group-0 = { Tmp-String-0 = "This is a string", Tmp-String-0 = "This is another one", Tmp-Octets-0 = 0x000504030201, Tmp-Integer-0 = 7331 }') {
+&result_string := "%pairs(request.Tmp-Group-0)"
+if !(&result_string == 'Tmp-Group-0 = { Filter-Id = "This is a string", Filter-Id = "This is another one", Class = 0x000504030201, NAS-Port = 7331 }') {
test_fail
}
&request -= &Tmp-Group-0[*]
-if (&request.Tmp-Group-0.Tmp-String-0) {
+if (&request.Tmp-Group-0.Filter-Id) {
test_fail
}
#
# Parse pairs from a string!
#
-&request += "%{Tmp-String-6}"
-if !(&request.Tmp-Group-0.Tmp-String-0 == 'This is a string') {
+&request += "%{result_string}"
+if !(&request.Tmp-Group-0.Filter-Id == 'This is a string') {
test_fail
}
#
# PRE: edit-list-remove if
#
+string salt
+string result_string
+octets result_octets
+
&control := {}
-&Tmp-String-0 := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
+&salt := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
#
# Unencoded Password.Cleartext in password with header
#
# Base64 encoded Password.Cleartext in password with header
#
-&Tmp-String-1 := "{clear}%{User-Password}"
+&result_string := "{clear}%{User-Password}"
&control := {
- &Password.With-Header = %base64.encode(%{Tmp-String-1})
+ &Password.With-Header = %base64.encode(%{result_string})
}
pap.authorize
# Hex encoded SSHA password
#
&control := {
- &Password.With-Header = "{ssha}%hex(%sha1(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
+ &Password.With-Header = "{ssha}%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
}
pap.authorize
#
# Base64 encoded SSHA password
#
-&control := {
- &Tmp-String-1 = "%hex(%sha1(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
-}
+&result_string := "%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
+&result_octets := "%bin(%{result_string})"
# To Base64
-&control.Tmp-String-1 := "%base64.encode(%{control.Tmp-Octets-0})"
-&control.Password.With-Header := "{ssha}%{control.Tmp-String-1}"
+&result_string := "%base64.encode(%{result_octets})"
+&control.Password.With-Header := "{ssha}%{result_string}"
pap.authorize
pap.authenticate {
reject = 1
+ fail = 2
}
if (reject) {
test_fail
#
# Base64 of Base64 encoded SSHA password
#
-&control := {
- &Tmp-String-1 = "%hex(%sha1(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
-}
+&result_string := "%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
+&result_octets := "%bin(%{result_string})"
# To Base64
-&control.Tmp-String-1 := "{ssha}%base64.encode(%{control.Tmp-Octets-0})"
-&control.Password.With-Header := "%base64.encode(%{control.Tmp-String-1})"
+&result_string := "{ssha}%base64.encode(%{result_octets})"
+&control.Password.With-Header := "%base64.encode(%{result_string})"
pap.authorize
pap.authenticate {
#
# PRE: update if pap
#
+string salt
+string result_string
+octets result_octets
#
# @todo - When fully converted, this crashes on ubsan issues.
}
&control := {}
-&Tmp-String-0 := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
+&salt := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
#
# Hex encoded SSHA2-512 password
#
&control += {
- &Password.With-Header = "{ssha512}%hex(%sha2_512(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
+ &Password.With-Header = "{ssha512}%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
}
pap.authorize
#
# Base64 encoded SSHA2-512 password
#
-&control.Tmp-String-1 := "%hex(%sha2_512(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
+&result_string := "%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
+&result_octets := "%bin(%{result_string})"
# To Base64
-&control.Tmp-String-1 := "%base64.encode(%{control.Tmp-Octets-0})"
+&result_string := "%base64.encode(%{result_octets})"
&control += {
- &Password.With-Header = "{ssha512}%{control.Tmp-String-1}"
+ &Password.With-Header = "{ssha512}%{result_string}"
}
pap.authorize
#
# Base64 of Base64 encoded SSHA2-512 password
#
-&control.Tmp-String-1 := "%hex(%sha2_512(%{User-Password}%{Tmp-String-0}))%hex(%{Tmp-String-0})"
+&result_string := "%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&control.Tmp-Octets-0 := "%bin(%{control.Tmp-String-1})"
+&result_octets := "%bin(%{result_string})"
# To Base64
-&control.Tmp-String-1 := "{ssha512}%base64.encode(%{control.Tmp-Octets-0})"
+&result_string := "{ssha512}%base64.encode(%{result_octets})"
&control += {
- &Password.With-Header = "%base64.encode(%{control.Tmp-String-1})"
+ &Password.With-Header = "%base64.encode(%{result_string})"
}
pap.authorize
parallel {
group {
&parent.control += {
- &Tmp-Integer-0 = 1
+ &NAS-Port = 1
}
}
group {
&parent.control += {
- &Tmp-Integer-0 = 3
+ &NAS-Port = 3
}
}
group {
&parent.control += {
- &Tmp-Integer-0 = 5
+ &NAS-Port = 5
}
}
group {
&parent.control += {
- &Tmp-Integer-0 = 7
+ &NAS-Port = 7
}
}
}
-if (!(%{control.Tmp-Integer-0[#]} == 4)) {
+if (!(%{control.NAS-Port[#]} == 4)) {
test_fail
}
parallel {
fail
group { # This should *NOT* be dispatched
- &Tmp-String-0 := 'foo'
+ &Filter-Id := 'foo'
}
}
actions {
if (!fail) {
test_fail
}
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
fail = 10 # Higher priority than ok and no longer action return
}
group { # This should now be dispatched
- &parent.request.Tmp-String-0 := 'foo'
+ &parent.request.Filter-Id := 'foo'
}
}
actions {
if (!fail) {
test_fail
}
-if (!(&Tmp-String-0 == 'foo')) {
+if (!(&Filter-Id == 'foo')) {
test_fail
}
parallel {
reschedule
group {
- &parent.request.Tmp-String-0 := 'foo'
+ &parent.request.Filter-Id := 'foo'
}
}
-if (!(&Tmp-String-0 == 'foo')) {
+if (!(&Filter-Id == 'foo')) {
test_fail
}
-&Tmp-String-0 := "%rand('-1')"
+string result_string
+uint32 result_integer
+
+&result_string := "%rand('-1')"
#
# Negative limit should have failed assignment
#
-if !(&Tmp-String-0 == "") {
+if !(&result_string == "") {
test_fail
}
-&Tmp-String-0 := "%rand('hello world')"
+&result_string := "%rand('hello world')"
#
# Invalid limit should have failed assignment
#
-if !(&Tmp-String-0 == "") {
+if !(&result_string == "") {
test_fail
}
-&Tmp-Integer-0 := %rand('123')
+&result_integer := %rand('123')
-if (!&Tmp-Integer-0) {
+if (!&result_integer) {
test_fail
}
#
# Make sure random number is within limit
#
-if (&Tmp-Integer-0 < 0 || &Tmp-Integer-0 > 123) {
+if (&result_integer < 0 || &result_integer > 123) {
test_fail
}
-&request += {
- &Tmp-String-1 = "%randstr(nnn)"
- &Tmp-String-2 = "%randstr(24a)"
- &Tmp-String-3 = "%randstr(1030aa)"
- &Tmp-String-5 = "%randstr(10b)"
-}
-
-#
-# This next assignment fails, so it can't go into the above list. If
-# it was there, then the entire list assignment would fail.
-#
-&Tmp-String-0 := "%randstr(%{Tmp-String-0})"
+string result_string
#
# Empty output on empty input
#
-if !(&Tmp-String-0 == "") {
+&result_string := "%randstr(%{result_string})"
+if !(&result_string == "") {
test_fail
}
#
# Check length of output
#
-if (!(%length(%{Tmp-String-1}) == 3)) {
+&result_string := "%randstr(nnn)"
+if (!(%length(%{result_string}) == 3)) {
test_fail
}
-if (!(%length(%{Tmp-String-2}) == 24)) {
+&result_string := "%randstr(24a)"
+if (!(%length(%{result_string}) == 24)) {
test_fail
}
#
# Check maximum repetition
#
-if (!(%length(%{Tmp-String-3}) == 1025)) {
+&result_string := "%randstr(1030aa)"
+if (!(%length(%{result_string}) == 1025)) {
test_fail
}
#
# Check invalid character class
#
-&Tmp-String-4 := "%randstr(G)"
+&result_string := "%randstr(G)"
-if !(&Tmp-String-4 == "") {
+if !(&result_string == "") {
test_fail
}
#
# Check repetition of binary output
#
-if (!(%length(%{Tmp-String-5}) == 10)) {
+&result_string := "%randstr(10b)"
+if (!(%length(%{result_string}) == 10)) {
test_fail
}
#
# The first one fails, so the second one is used
#
+uint32 count
+
+&count := 0
&request += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-1 = 0
- &Tmp-Integer-1 = 1
- &Tmp-Integer-1 = 2
- &Tmp-Integer-1 = 3
- &Tmp-Integer-1 = 4
- &Tmp-Integer-1 = 5
- &Tmp-Integer-1 = 6
- &Tmp-Integer-1 = 7
- &Tmp-Integer-1 = 8
- &Tmp-Integer-1 = 9
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9
}
redundant {
#
# Loop 0..9
#
-foreach &Tmp-Integer-1 {
+foreach &NAS-Port {
redundant {
group {
# fail on even numbered values, succeed on odd numbered ones
fail
}
else {
- &Tmp-Integer-0 += 1
+ &count += 1
&request += {
- &Tmp-String-0 = "Succeed odd %{Foreach-Variable-0} %{Tmp-Integer-0}"
+ &Reply-Message = "Succeed odd %{Foreach-Variable-0} %{count}"
}
ok
}
fail
}
else {
- &Tmp-Integer-0 += 1
+ &count += 1
&request += {
- &Tmp-String-0 = "Succeed even %{Foreach-Variable-0} %{Tmp-Integer-0}"
+ &Reply-Message = "Succeed even %{Foreach-Variable-0} %{count}"
}
ok
}
}
}
-if (!(&Tmp-Integer-0 == %{Tmp-Integer-1[#]})) {
+if (!(&count == %{NAS-Port[#]})) {
test_fail
}
#
# The first one fails, so the second one is used
#
+uint32 count
+
+&count := 0;
&request += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-1 = 0
- &Tmp-Integer-1 = 1
- &Tmp-Integer-1 = 2
- &Tmp-Integer-1 = 3
- &Tmp-Integer-1 = 4
- &Tmp-Integer-1 = 5
- &Tmp-Integer-1 = 6
- &Tmp-Integer-1 = 7
- &Tmp-Integer-1 = 8
- &Tmp-Integer-1 = 9
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
+ &NAS-Port = 4
+ &NAS-Port = 5
+ &NAS-Port = 6
+ &NAS-Port = 7
+ &NAS-Port = 8
+ &NAS-Port = 9
}
#
# Loop 0..9
#
-foreach &Tmp-Integer-1 {
+foreach &NAS-Port {
redundant-load-balance {
group {
# fail on even numbered values, succeed on odd numbered ones
fail
}
else {
- &Tmp-Integer-0 += 1
+ &count += 1
&request += {
- &Tmp-String-0 = "Succeed odd %{Foreach-Variable-0} %{Tmp-Integer-0}"
+ &Reply-Message = "Succeed odd %{Foreach-Variable-0} %{count}"
}
ok
}
fail
}
else {
- &Tmp-Integer-0 += 1
+ &count += 1
&request += {
- &Tmp-String-0 = "Succeed even %{Foreach-Variable-0} %{Tmp-Integer-0}"
+ &Reply-Message = "Succeed even %{Foreach-Variable-0} %{count}"
}
ok
}
}
}
-if (!(&Tmp-Integer-0 == %{Tmp-Integer-1[#]})) {
+if (!(&count == %{NAS-Port[#]})) {
test_fail
}
redundant {
- map test-fail &Tmp-String-0 {
- &Tmp-Integer-0 := '$[3][2]'
+ map test-fail &Filter-Id {
+ &NAS-Port := '$[3][2]'
}
noop
}
-if (noop || (&Tmp-Integer-0 == 4294967295)) {
+if (noop || (&NAS-Port == 4294967295)) {
success
} else {
fail
# Nested redundant blocks.
#
#
-&request += {
- &Tmp-Integer-2 = 0
- &Tmp-Integer-3 = 0
- &Tmp-Integer-4 = 0
- &Tmp-Integer-5 = 0
-}
+uint32 count1
+uint32 count2
+uint32 count3
+uint32 count4
+
+&count1 = 0
+&count2 = 0
+&count3 = 0
+&count4 = 0
redundant {
redundant-load-balance {
group {
- &Tmp-Integer-2 += 1
+ &count1 += 1
fail
}
group {
- &Tmp-Integer-3 += 1
+ &count2 += 1
fail
}
group {
- &Tmp-Integer-4 += 1
+ &count3 += 1
fail
}
group {
- &Tmp-Integer-5 += 1
+ &count4 += 1
fail
}
}
return
}
-if (!(&Tmp-Integer-2 == 1)) {
+if (!(&count1 == 1)) {
test_fail
}
-if (!(&Tmp-Integer-3 == 1)) {
+if (!(&count2 == 1)) {
test_fail
return
}
-if (!(&Tmp-Integer-4 == 1)) {
+if (!(&count3 == 1)) {
test_fail
return
}
-if (!(&Tmp-Integer-5 == 1)) {
+if (!(&count4 == 1)) {
test_fail
return
}
#
# PRE: if
#
+string test_string1
+string test_string2
#
# Strings which are expanded in a regex have regex special
# characters escaped. Because the input strings are unsafe.
#
-&request += {
- &Tmp-String-0 = "%taint(example.com)"
- &Tmp-String-1 = "%taint(exampleXcom)"
-}
+&test_string1 := "%taint(example.com)"
+&test_string2 := "%taint(exampleXcom)"
-if ("exampleXcom" =~ /%{Tmp-String-0}/) {
+if ("exampleXcom" =~ /%{test_string1}/) {
test_fail
}
-elsif (&Tmp-String-1 =~ /%{Tmp-String-0}/) {
+if (&test_string2 =~ /%{test_string1}/) {
test_fail
}
#
# PRE: if regex-escape
#
+string test_string1
+string test_string2
#
# Strings which are expanded in a regex have regex special
# characters escaped. Because the input strings are unsafe.
#
-&request += {
- &Tmp-String-0 = "example.com"
- &Tmp-String-1 = "^foo$bar"
-}
+&test_string1 = "example.com"
+&test_string2 = "^foo$bar"
-if !(&Tmp-String-0 =~ /example\.com$/) {
+if !(&test_string1 =~ /example\.com$/) {
test_fail
}
-elsif !(&Tmp-String-1 =~ /\^foo\$bar/) {
+elsif !(&test_string2 =~ /\^foo\$bar/) {
test_fail
}
# PRE: if
+uint32 count
-&Tmp-Integer-0 := 0
+&count := 0
group {
- &Tmp-Integer-0 += 1
+ &count += 1
noop
actions {
}
}
-if (!(&Tmp-Integer-0 == 3)) {
+if (!(&count == 3)) {
test_fail
}
# PRE: if return foreach
#
&control += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-0 = 1
- &Tmp-Integer-0 = 2
- &Tmp-Integer-0 = 3
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
}
-foreach &control.Tmp-Integer-0 {
+foreach &control.NAS-Port {
policy_return
# Should continue executing
}
&control -= {
- &Tmp-Integer-0 == "%{Foreach-Variable-0}"
+ &NAS-Port == "%{Foreach-Variable-0}"
}
}
# Everything should have been removed except
-# the last incidence of &Tmp-Integer-0
-if (!&control.Tmp-Integer-0) {
+# the last incidence of &NAS-Port
+if (!&control.NAS-Port) {
test_fail
}
-if (!(&control.Tmp-Integer-0[0] == 2)) {
+if (!(&control.NAS-Port[0] == 2)) {
test_fail
}
# PRE: if return foreach
#
&control += {
- &Tmp-Integer-0 = 0
- &Tmp-Integer-0 = 1
- &Tmp-Integer-0 = 2
- &Tmp-Integer-0 = 3
+ &NAS-Port = 0
+ &NAS-Port = 1
+ &NAS-Port = 2
+ &NAS-Port = 3
}
group {
- foreach &control.Tmp-Integer-0 {
+ foreach &control.NAS-Port {
if ("%{Foreach-Variable-0}" == '2') {
accept
success
#
# PRE: if
#
-&request += {
- &Tmp-String-0 = "This is a string\n"
- &Tmp-Octets-0 = 0x000504030201
- &Tmp-String-1 = "what do ya want for nothing?"
- &Tmp-String-2 = "Jefe"
- &Tmp-String-3 = ""
-}
+string test_string
+string test_hmac_key
+string test_hmac_data
+string dummy_string
-&request += {
- &Tmp-Octets-2 = %sha1("This is a string\n")
- &Tmp-Octets-3 = %sha1("%{Tmp-String-0}")
- &Tmp-Octets-4 = %sha1("%{request.Tmp-String-0}")
- &Tmp-Octets-5 = %sha1("%{request.Tmp-Octets-9}")
- &Tmp-Octets-6 = %hmacsha1("%{Tmp-String-1}", "%{Tmp-String-2}")
- &Tmp-Octets-7 = %hmacsha1("%{Tmp-String-3}", "%{Tmp-String-3}")
-}
+octets result_octets
+
+&test_string := "This is a string\n"
+&test_hmac_key := "what do ya want for nothing?"
+&test_hmac_data := "Jefe"
#
# Put "This is a string" into a file and call "sha1sum" on it.
# You should get this string.
#
-if (!(&Tmp-Octets-2 == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
- test_fail
-}
-
-if (!(&Tmp-Octets-3 == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
+&result_octets := %sha1("This is a string\n")
+if (!(&result_octets == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
test_fail
}
-if (!(&Tmp-Octets-4 == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
+&result_octets := %sha1("%{test_string}")
+if (!(&result_octets == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
test_fail
}
#
# SHA1 of empty string
#
-if (!(&Tmp-Octets-5 == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709)) {
+&result_octets := %sha1("%{dummy_string}")
+if (!(&result_octets == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709)) {
test_fail
}
#
# SHA1 HMAC with attribute references
#
-if (!(&Tmp-Octets-6 == 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79)) {
+&result_octets := %hmacsha1("%{test_hmac_key}", "%{test_hmac_data}")
+if (!(&result_octets == 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79)) {
test_fail
}
#
# SHA1 HMAC with empty key and data
#
-if (!(&Tmp-Octets-7 == 0xfbdb1d1b18aa6c08324b7d64b71fb76370690e1d)) {
+&dummy_string := ''
+&result_octets := %hmacsha1("%{dummy_string}", "%{dummy_string}")
+if (!(&result_octets == 0xfbdb1d1b18aa6c08324b7d64b71fb76370690e1d)) {
test_fail
}
-&Tmp-String-1 := "hello"
+string test_string
+octets result_octets
+&test_string := "hello"
#
# SHA1 HMAC with missing key should fail
#
-&Tmp-Octets-1 := %hmacsha1(%{Tmp-String-1}, ) # ERROR
-if &Tmp-Octets-1 {
+&result_octets := %hmacsha1(%{test_string}, ) # ERROR
+if &result_octets {
test_fail
}
success
#
# PRE: update if
#
-&Tmp-String-0 := "This is a string\n"
-&Tmp-Octets-0 := 0x000504030201
+string test_string
+octets test_octets
+octets dummy_octets
+octets result_octets
-&Tmp-Octets-1 := %sha2_256("This is a string\n")
-&Tmp-Octets-2 := %sha2_256(%{Tmp-String-0})
-&Tmp-Octets-3 := %sha2_256(%{request.Tmp-String-0})
-&Tmp-Octets-4 := %sha2_256(%{request.Tmp-Octets-0})
-&Tmp-Octets-5 := %sha2_256(%{request.Tmp-Octets-9})
+&test_string := "This is a string\n"
+&test_octets := 0x000504030201
#
# Put "This is a string" into a file and call "sha2_256sum" on it.
# You should get this string.
#
-if (!(&Tmp-Octets-1 == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
+&result_octets := %sha2_256("This is a string\n")
+if (!(&result_octets == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
test_fail
}
-if (!(&Tmp-Octets-2 == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
- test_fail
-}
-
-if (!(&Tmp-Octets-3 == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
+&result_octets := %sha2_256(%{test_string})
+if (!(&result_octets == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
test_fail
}
#
# SHA256 should also be able to cope with references to octet attributes
#
-if (!(&Tmp-Octets-4 == 0xf307e202b881fded70e58017aa0c4d7b29c76ab25d02bf078301a5f6635187eb)) {
+&result_octets := %sha2_256(%{test_octets})
+if (!(&result_octets == 0xf307e202b881fded70e58017aa0c4d7b29c76ab25d02bf078301a5f6635187eb)) {
test_fail
}
#
# SHA256 of empty string
#
-if (!(&Tmp-Octets-5 == 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)) {
+&result_octets := %sha2_256(%{dummy_octets})
+if (!(&result_octets == 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)) {
test_fail
}
# SHA512 and SHA256 share common code paths, so the tests don't need to be
# as exhaustive.
#
-&Tmp-Octets-1 := %sha2_512("This is a string\n")
-&Tmp-Octets-2 := %sha2_512(%{Tmp-String-0})
-&Tmp-Octets-3 := %sha2_512(%{request.Tmp-Octets-0})
-
-if (!(&Tmp-Octets-1 == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
+&result_octets := %sha2_512("This is a string\n")
+if (!(&result_octets == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
test_fail
}
-if (!(&Tmp-Octets-2 == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
+&result_octets := %sha2_512(%{test_string})
+if (!(&result_octets == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
test_fail
}
-if (!(&Tmp-Octets-3 == 0xde80271eb5e03a1c24dd0cd823a22305a743ee3a54f1de5bf97adbf56984561154bfb6928b1da4ccc3f5dde9f4032ad461937b60b9ace4ad3898cf45c90596d7)) {
+&result_octets := %sha2_512(%{test_octets})
+if (!(&result_octets == 0xde80271eb5e03a1c24dd0cd823a22305a743ee3a54f1de5bf97adbf56984561154bfb6928b1da4ccc3f5dde9f4032ad461937b60b9ace4ad3898cf45c90596d7)) {
test_fail
}
-&Tmp-Integer-0 := -1000 # ERROR
+&NAS-Port := -1000 # ERROR
test_fail
#
# PRE: subrequest
#
-&control.Tmp-String-0 := "Access-Request"
+&control.Filter-Id := "Access-Request"
#
# Subrequest with an attribute reference
#
-subrequest &control.Tmp-String-0 {
+subrequest &control.Filter-Id {
&parent.control.User-Name := 'bob'
success
#
# PRE: subrequest
#
-&Tmp-String-1 := 'testing'
+&Filter-Id := 'testing'
# Cancel in subrequest
subrequest Access-Request {
detach
# Smoke test, check for crashes
- if (&parent.Tmp-String-1 == 'testing') {
+ if (&parent.Filter-Id == 'testing') {
test_fail
}
- &parent.Tmp-String-2 = 'testing'
+ &parent.Reply-Message = 'testing'
# As we're detached this failure doesn't do anything
test_fail
}
# Should not have been set from detached child
-if (&Tmp-String-2 && (&Tmp-String-2 == 'testing')) {
+if (&Reply-Message && (&Reply-Message == 'testing')) {
test_fail
}
&User-Name := "joe"
&outer.request += {
- &Tmp-String-0 = ¤t.User-Name
- &Tmp-String-1 = &parent.User-Name
- &Tmp-String-2 = &parent.parent.User-Name
- &Tmp-String-3 = &parent.parent.parent.User-Name
- &Tmp-String-4 = &outer.User-Name
- &Tmp-String-5 = ¤t.outer.User-Name
- &Tmp-String-6 = &parent.current.outer.User-Name
- &Tmp-String-7 = "%{parent.parent.parent.parent.User-Name}"
- &Tmp-String-8 = "%{outer.parent.User-Name}"
+ &Filter-Id = ¤t.User-Name
+ &Filter-Id = &parent.User-Name
+ &Filter-Id = &parent.parent.User-Name
+ &Filter-Id = &parent.parent.parent.User-Name
+ &Filter-Id = &outer.User-Name
+ &Filter-Id = ¤t.outer.User-Name
+ &Filter-Id = &parent.current.outer.User-Name
+ &Filter-Id = "%{parent.parent.parent.parent.User-Name}"
+ &Filter-Id = "%{outer.parent.User-Name}"
}
}
}
test_fail
}
-if !(&Tmp-String-0 == 'joe') {
+if !(&Filter-Id[0] == 'joe') {
test_fail
}
-if !(&Tmp-String-1 == 'jim') {
+if !(&Filter-Id[1] == 'jim') {
test_fail
}
-if !(&Tmp-String-2 == 'obo') {
+if !(&Filter-Id[2] == 'obo') {
test_fail
}
-if !(&Tmp-String-3 == 'bob') {
+if !(&Filter-Id[3] == 'bob') {
test_fail
}
-if !(&Tmp-String-4 == 'bob') {
+if !(&Filter-Id[4] == 'bob') {
test_fail
}
-if !(&Tmp-String-5 == 'bob') {
+if !(&Filter-Id[5] == 'bob') {
test_fail
}
-if !(&Tmp-String-6 == 'bob') {
+if !(&Filter-Id[6] == 'bob') {
test_fail
}
-if !(&Tmp-String-7 == "") {
+if !(&Filter-Id[7] == "") {
test_fail
}
-if !(&Tmp-String-8 == "") {
+if !(&Filter-Id[8] == "") {
test_fail
}
subrequest Access-Request {
- &parent.request.Tmp-String-0 := "testing1234"
+ &parent.request.Filter-Id := "testing1234"
return
#
# Should be ignored
#
- &parent.request.Tmp-String-1 := "testing1234"
+ &parent.request.Reply-Message := "testing1234"
}
-if (&Tmp-String-1) {
+if (&Reply-Message) {
test_fail
}
-if (!(&Tmp-String-0 == "testing1234")) {
+if (!(&Filter-Id == "testing1234")) {
test_fail
}
test_fail
}
- &reply.Tmp-String-0 := 'hello from subrequest'
+ &reply.Filter-Id := 'hello from subrequest'
}
if (!&reply.Tmp-Group-0) {
test_fail
}
-if (!&reply.Tmp-Group-0.Tmp-String-0) {
+if (!&reply.Tmp-Group-0.Filter-Id) {
test_fail
}
-if !(&reply.Tmp-Group-0.Tmp-String-0 == 'hello from subrequest') {
+if !(&reply.Tmp-Group-0.Filter-Id == 'hello from subrequest') {
test_fail
}
test_fail
}
- &reply.Tmp-String-0 := 'hello from subrequest'
+ &reply.Filter-Id := 'hello from subrequest'
}
}
test_fail
}
-if (!&reply.Tmp-Group-0.Tmp-Group-0.Tmp-String-0) {
+if (!&reply.Tmp-Group-0.Tmp-Group-0.Filter-Id) {
test_fail
}
-if !(&reply.Tmp-Group-0.Tmp-Group-0.Tmp-String-0 == 'hello from subrequest') {
+if !(&reply.Tmp-Group-0.Tmp-Group-0.Filter-Id == 'hello from subrequest') {
test_fail
}
# Expected answer
#
Packet-Type == Access-Accept
-Tmp-Group-0 == { Tmp-Group-0 == { Tmp-String-0 == 'hello from subrequest' } }
+Tmp-Group-0 == { Tmp-Group-0 == { Filter-Id == 'hello from subrequest' } }
Result-Status == "success"
# Expected answer
#
Packet-Type == Access-Accept
-Tmp-Group-0 == { Tmp-String-0 == 'hello from subrequest' }
+Tmp-Group-0 == { Filter-Id == 'hello from subrequest' }
Result-Status == "success"
-&Tmp-String-0 := 'foo'
+string test_string
+&test_string := 'foo'
-switch "%tolower(%{Tmp-String-0})" {
+switch "%tolower(%{test_string})" {
case 'foo' {
success
}
}
}
-switch "%{Tmp-String-0}" {
+switch "%{test_string}" {
case 'foo' {
success
}
#
# PRE: xlat-delay
#
+float32 a
#
# Set a timeout which will fire, and cause the block to fail.
#
redundant {
timeout 0.01s {
- &Tmp-Float-0 := %delay_10s(0.1)
+ &a := %delay_10s(0.1)
test_fail
}
redundant {
timeout "0.01" {
- &Tmp-Float-0 := %delay_10s(0.1)
+ &a := %delay_10s(0.1)
test_fail
}
#
# PRE: if
#
-&Tmp-String-0 := "AbCdE"
-&Tmp-String-0 := %tolower(%{Tmp-String-0})
-&Tmp-String-1 := %tolower(AAbbCCdd)
-
-#
-# Doesn't exist
-#
-&Tmp-String-2 := "%tolower(%{Tmp-String-9})"
+string test_string
+string dummy_string
+&test_string := "AbCdE"
+&test_string := %tolower(%{test_string})
-if (!(&Tmp-String-0 == "abcde")) {
+if !(&test_string == "abcde") {
test_fail
}
-if (!(&Tmp-String-1 == "aabbccdd")) {
+&test_string := %tolower(AAbbCCdd)
+if !(&test_string == "aabbccdd") {
test_fail
}
-if !(&Tmp-String-2 == "") {
+#
+# Doesn't exist
+#
+&test_string := "%tolower(%{dummy_string})"
+if !(&test_string == "") {
test_fail
}
#
# PRE: if
#
-&Tmp-String-0 := "AbCdE"
+string test_string
+string dummy_string
-&Tmp-String-0 := %toupper(%{Tmp-String-0})
-&Tmp-String-1 := %toupper(AAbbCCdd)
-&Tmp-String-2 := "%toupper(%{Tmp-String-9})"
-
-if (!(&Tmp-String-0 == "ABCDE")) {
+&test_string := "AbCdE"
+&test_string := %toupper(%{test_string})
+if (!(&test_string == "ABCDE")) {
test_fail
}
-if (!(&Tmp-String-1 == "AABBCCDD")) {
+&test_string := %toupper(AAbbCCdd)
+if (!(&test_string == "AABBCCDD")) {
test_fail
}
-if !(&Tmp-String-2 == "") {
+&test_string := "%toupper(%{dummy_string})"
+if !(&test_string == "") {
test_fail
}
# cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c <n>
# 8192 - 0x (2) - '' (2) there are unlikely to be any static buffers this big outside of the conffile parser
-&Tmp-Octets-0 := 0x\
+octets test_octets
+string result_string
+
+&test_octets := 0x\
d8abccb7834711af1de1812be2579febe946f5d7beef6fa5c7074c0cb917e9b91e23e14b016f27610097c16c0e0fad88176e077b24198c770746159\
05b8810d1c8b774d98889fa5c6027cde5e9c56dd4f7c48298c7713aeca5ba5dcfd506032ad05b1396f50e825b633d5a6af0dce6181b640287e03a65\
8734df46a86341556f28455b3f377313a5a2ac8c8267b8a5de559b95f9b493a68b9e0278485f9e3914d702b2b7b90ee85ff393461f197386d09b836\
3ae4bcef324b9a3f47ba5c835b54a010ca42f3b9cc5368278c148c9b02ea8c4c9f244fd49f
# Actual length of octet string is 4083 bytes
-if (!(%length(%{Tmp-Octets-0}) == 4083)) {
+if (!(%length(%{test_octets}) == 4083)) {
test_fail
}
# Octets are expanded to 8168 hexits
-if !("0x%hex(%{Tmp-Octets-0})" =~ /^0x([0-9a-f]+)$/) {
+if !("0x%hex(%{test_octets})" =~ /^0x([0-9a-f]+)$/) {
test_fail
}
-&Tmp-String-0 := "%{1}"
+&result_string := "%{1}"
-if (!("%length(%{Tmp-String-0})" == 8166)) {
+if (!("%length(%{result_string})" == 8166)) {
test_fail
}
#
# PRE: if edit
#
+octets test_octets
+string test_string
+ipaddr result_ipaddr
+uint32 result_integer
+string result_string
+
&Framed-IP-Address := 127.0.0.1
-&Tmp-Octets-0 := &Framed-IP-Address
+&test_octets := &Framed-IP-Address
-&Tmp-String-0 := "%unpack(%{Tmp-Octets-0}, 0, 'ipaddr')"
-&Tmp-IP-Address-0 := "%unpack(%{Tmp-Octets-0}, 0, 'ipaddr')"
+&test_string := "%unpack(%{test_octets}, 0, 'ipaddr')"
+&result_ipaddr := "%unpack(%{test_octets}, 0, 'ipaddr')"
-if !(&Tmp-String-0 == "127.0.0.1") {
+if !(&test_string == "127.0.0.1") {
test_fail
}
-if !(&Tmp-IP-Address-0 == 127.0.0.1) {
+if !(&result_ipaddr == 127.0.0.1) {
test_fail
}
-&Tmp-Octets-0 := 0x000001020304
-&Tmp-Integer-0 := "%unpack(%{Tmp-Octets-0}, 4, 'uint16')"
+&test_octets := 0x000001020304
+&result_integer := "%unpack(%{test_octets}, 4, 'uint16')"
# Octets 4 and 5 == 0x0304 == 772
-if ~(&Tmp-Integer-0 == 772) {
+if ~(&result_integer == 772) {
test_fail
}
# truncation
-&Tmp-String-0 := "0x0011223344556677"
-&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'ether')"
-if !(&Tmp-String-1 == "00:11:22:33:44:55") {
+&test_string := "0x0011223344556677"
+&result_string := "%unpack(%{test_string}, 0, 'ether')"
+if !(&result_string == "00:11:22:33:44:55") {
test_fail
}
-&Tmp-String-0 := "0x48656C6C6F"
-&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')"
-if !(&Tmp-String-1 == "Hello") {
+&test_string := "0x48656C6C6F"
+&result_string := "%unpack(%{test_string}, 0, 'string')"
+if !(&result_string == "Hello") {
test_fail
}
# Offset beyond data length
-&request -= &Tmp-String-1[*]
-&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 10, 'string')"
+&result_string := "%unpack(%{test_string}, 10, 'string')"
-if !(&Tmp-String-1 == "") {
+if !(&result_string == "") {
test_fail
}
&request -= &Module-Failure-Message[*]
# Invalid destination data type
-&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'thing')"
-if !(&Tmp-String-1 == "") {
+&result_string := "%unpack(%{test_string}, 0, 'thing')"
+if !(&result_string == "") {
test_fail
}
}
# Invalid source data type
-&Tmp-String-1 := "%unpack(%{Tmp-Integer-0}, 0, 'string')"
-if !(&Tmp-String-1 == "") {
+&result_string := "%unpack(%{result_integer}, 0, 'string')"
+if !(&result_string == "") {
test_fail
}
&request -= &Module-Failure-Message[*]
# Invalid hex string
-&Tmp-String-0 := '0x014sdgw'
-&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')"
+&test_string := '0x014sdgw'
+&result_string := "%unpack(%{test_string}, 0, 'string')"
-if !(&Tmp-String-1 == "") {
+if !(&result_string == "") {
test_fail
}
&request -= &Module-Failure-Message[*]
# Zero length hex string
-&Tmp-String-0 := '0x'
-&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')"
+&test_string := '0x'
+&result_string := "%unpack(%{test_string}, 0, 'string')"
-if !(&Tmp-String-1 == "") {
+if !(&result_string == "") {
test_fail
}
#
update request {
- &Tmp-String-0 := 'foobarbaz'
- &Tmp-Integer-0 := 123456789
- &Tmp-IP-Address-0 := 192.0.2.1
+ &Filter-Id := 'foobarbaz'
+ &NAS-Port := 123456789
+ &Framed-IP-Address := 192.0.2.1
}
-if (!((&Tmp-String-0 == 'foobarbaz')) || (!(&Tmp-Integer-0 == 123456789)) || (!(&Tmp-IP-Address-0 == 192.0.2.1))) {
+if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789)) || (!(&Framed-IP-Address == 192.0.2.1))) {
test_fail
}
}
# All attributes should now of been removed
-if ((&Tmp-String-0 && (&Tmp-String-0 == 'foobarbaz')) || \
- (&Tmp-Integer-0 && (&Tmp-Integer-0 == 123456789)) || \
- (&Tmp-IP-Address-0 && (&Tmp-IP-Address-0 == 192.0.2.1))) {
+if ((&Filter-Id && (&Filter-Id == 'foobarbaz')) || \
+ (&NAS-Port && (&NAS-Port == 123456789)) || \
+ (&Framed-IP-Address && (&Framed-IP-Address == 192.0.2.1))) {
test_fail
}
# PRE: update
#
update control {
- &Tmp-Integer-0 := 5
- &Tmp-Integer-0 += 10
- &Tmp-Integer-0 += 15
- &Tmp-Integer-0 += 20
- &Tmp-String-0 := 'foo'
- &Tmp-String-0 += 'baz'
- &Tmp-String-0 += 'boink'
+ &NAS-Port := 5
+ &NAS-Port += 10
+ &NAS-Port += 15
+ &NAS-Port += 20
+ &Filter-Id := 'foo'
+ &Filter-Id += 'baz'
+ &Filter-Id += 'boink'
}
# Reset the request list
# Integer ==
#
update request {
- &Tmp-Integer-0 == 10
+ &NAS-Port == 10
}
-if (!(&Tmp-Integer-0[0] == 10)) {
+if (!(&NAS-Port[0] == 10)) {
test_fail
}
-if (!(%{Tmp-Integer-0[#]} == 1)) {
+if (!(%{NAS-Port[#]} == 1)) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
# String ==
#
update request {
- &Tmp-String-0 == 'baz'
+ &Filter-Id == 'baz'
}
-if (!(&Tmp-String-0[0] == 'baz')) {
+if (!(&Filter-Id[0] == 'baz')) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 1)) {
+if (!(%{Filter-Id[#]} == 1)) {
test_fail
}
# Integer <
#
update request {
- &Tmp-Integer-0 < 10
+ &NAS-Port < 10
}
-if (!(&Tmp-Integer-0[0] == 5)) {
+if (!(&NAS-Port[0] == 5)) {
test_fail
}
-if (!(%{Tmp-Integer-0[#]} == 1)) {
+if (!(%{NAS-Port[#]} == 1)) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
# Integer >
#
update request {
- &Tmp-Integer-0 > 10
+ &NAS-Port > 10
}
-if (!(&Tmp-Integer-0[0] == 15)) {
+if (!(&NAS-Port[0] == 15)) {
test_fail
}
-if (!(&Tmp-Integer-0[1] == 20)) {
+if (!(&NAS-Port[1] == 20)) {
test_fail
}
-if (!(%{Tmp-Integer-0[#]} == 2)) {
+if (!(%{NAS-Port[#]} == 2)) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
# Integer <=
#
update request {
- &Tmp-Integer-0 <= 10
+ &NAS-Port <= 10
}
-if (!(&Tmp-Integer-0[0] == 5)) {
+if (!(&NAS-Port[0] == 5)) {
test_fail
}
-if (!(&Tmp-Integer-0[1] == 10)) {
+if (!(&NAS-Port[1] == 10)) {
test_fail
}
-if (!(%{Tmp-Integer-0[#]} == 2)) {
+if (!(%{NAS-Port[#]} == 2)) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
# Integer >=
#
update request {
- &Tmp-Integer-0 >= 10
+ &NAS-Port >= 10
}
-if (!(&Tmp-Integer-0[0] == 10)) {
+if (!(&NAS-Port[0] == 10)) {
test_fail
}
-if (!(&Tmp-Integer-0[1] == 15)) {
+if (!(&NAS-Port[1] == 15)) {
test_fail
}
-if (!(&Tmp-Integer-0[2] == 20)) {
+if (!(&NAS-Port[2] == 20)) {
test_fail
}
-if (!(%{Tmp-Integer-0[#]} == 3)) {
+if (!(%{NAS-Port[#]} == 3)) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
# Integer !=
#
update request {
- &Tmp-Integer-0 != 10
+ &NAS-Port != 10
}
-if (!(&Tmp-Integer-0[0] == 5)) {
+if (!(&NAS-Port[0] == 5)) {
test_fail
}
-if (!(&Tmp-Integer-0[1] == 15)) {
+if (!(&NAS-Port[1] == 15)) {
test_fail
}
-if (!(&Tmp-Integer-0[2] == 20)) {
+if (!(&NAS-Port[2] == 20)) {
test_fail
}
-if (!(%{Tmp-Integer-0[#]} == 3)) {
+if (!(%{NAS-Port[#]} == 3)) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
&request := &control
update request {
- &Tmp-String-1 := 'baz'
- &Tmp-String-1 += 'boink'
+ &Callback-Id := 'baz'
+ &Callback-Id += 'boink'
}
#
# String (Intersection)
#
update request {
- &Tmp-String-0 == &Tmp-String-1[0]
+ &Filter-Id == &Callback-Id[0]
}
-if (!(&Tmp-String-0[0] == &Tmp-String-1[0])) {
+if (!(&Filter-Id[0] == &Callback-Id[0])) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 1)) {
+if (!(%{Filter-Id[#]} == 1)) {
test_fail
}
# This was parsed in the old edit code, but never did anything!
#
&Tmp-Group-0 := { # ERROR
- Tmp-String-0 = "foo"
+ Filter-Id = "foo"
}
}
-if !&reply.Tmp-Group-0.Tmp-String-0 {
+if !&reply.Tmp-Group-0.Filter-Id {
test_fail
}
# PRE: update
#
update reply {
-# &Tmp-String-0 := "foo"
#
# This is a string, so it's NOT allowed.
#
- &Tmp-String-1 := { # ERROR
- Tmp-String-2 := "1.0"
+ &Filter-Id := { # ERROR
+ Reply-Message := "1.0"
}
}
#
update {
- &Tmp-String-0 := 0x626f62
+ &Filter-Id := 0x626f62
}
-if (!(&Tmp-String-0 == 'bob')) {
+if (!(&Filter-Id == 'bob')) {
test_fail
}
update {
- &Tmp-String-0 := '0x626f62'
+ &Filter-Id := '0x626f62'
}
-if (!(&Tmp-String-0 == '0x626f62')) {
+if (!(&Filter-Id == '0x626f62')) {
test_fail
}
# Form attribute references with xlats
#
update request {
- &Tmp-String-0 += 'foo'
- &Tmp-String-0 += 'bar'
- &Tmp-String-1 += 'baz'
+ &Filter-Id += 'foo'
+ &Filter-Id += 'bar'
+ &Reply-Message += 'baz'
#
# @fixme - EDIT - how the heck did this ever work?
&control !* ANY
}
-if (!(&Tmp-String-0[0] == 'foo')) {
+if (!(&Filter-Id[0] == 'foo')) {
test_fail
}
&request := &control
}
-if (&Tmp-String-0 || &Tmp-String-1) {
+if (&Filter-Id || &Reply-Message) {
test_fail
}
#
-# Tmp-Octets-1 doesn't exist, so Tmp-Octets-0 shouldn't be created
+# State doesn't exist, so Class shouldn't be created
#
update request {
- &Tmp-Octets-0 := &Tmp-Octets-1
+ &Class := &State
}
-if (&Tmp-Octets-0) {
+if (&Class) {
test_fail
}
#
#
update request {
- &Tmp-String-0 := "%{Reply-Message}"
+ &Filter-Id := "%{Reply-Message}"
}
-if (!&Tmp-String-0) {
+if (!&Filter-Id) {
test_fail
}
-if (!(&Tmp-String-0 == '')) {
+if (!(&Filter-Id == '')) {
test_fail
}
# @fixme - EDIT - the new method is to simply omit the assignment
#
update request {
- &Tmp-Octets-0 := "%{Reply-Message}"
+ &Class := "%{Reply-Message}"
}
-if (!(&Tmp-Octets-0 == "")) {
+if (!(&Class == "")) {
test_fail
}
# Define initial test strings
update control {
- &Tmp-String-0 := 'foo'
- &Tmp-String-0 += 'baz'
+ &Filter-Id := 'foo'
+ &Filter-Id += 'baz'
}
# Reset the request list and add the test strings
# FIXME:
# Temporary way to add multiple copies of an attribute - this should become
-# &Tmp-String-0 += &control.Tmp-String-0 when multi copies of attributes
+# &Filter-Id += &control.Filter-Id when multi copies of attributes
# are copied again. Currently the desired syntax won't work due to tmpl_t only holding
# a single value_box - so when mapt_to_list_mod() builds the list of value for the rhs
# of the expression only the first one is copied to the tmpl_t. See around line 780
# of map_async.c
update {
- &Tmp-String-0 !* ANY
- &Tmp-String-0 += &control.Tmp-String-0[0]
- &Tmp-String-0 += &control.Tmp-String-0[1]
+ &Filter-Id !* ANY
+ &Filter-Id += &control.Filter-Id[0]
+ &Filter-Id += &control.Filter-Id[1]
}
# Prepend a single value
update request {
- &Tmp-String-0 ^= 'boink'
+ &Filter-Id ^= 'boink'
}
# The prepended value should be first followed by the other two
-if (!((&Tmp-String-0[0] == 'boink')) || (!(&Tmp-String-0[1] == 'foo')) || (!(%{Tmp-String-0[2]} == 'baz'))) {
+if (!((&Filter-Id[0] == 'boink')) || (!(&Filter-Id[1] == 'foo')) || (!(%{Filter-Id[2]} == 'baz'))) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 3)) {
+if (!(%{Filter-Id[#]} == 3)) {
test_fail
}
# Add an extra element to the start of control
update control {
- &Tmp-String-0 ^= 'wibble'
+ &Filter-Id ^= 'wibble'
}
# Prepend control to request
}
# The attributes should now be "wibble", "foo", "baz", "boink", "foo", "baz"
-if (!((&Tmp-String-0[0] == 'wibble')) || (!(&Tmp-String-0[1] == 'foo')) || (!(%{Tmp-String-0[2]} == 'baz')) || (!(&Tmp-String-0[3] == 'boink')) || (!(&Tmp-String-0[4] == 'foo')) || (!(&Tmp-String-0[5] == 'baz'))) {
+if (!((&Filter-Id[0] == 'wibble')) || (!(&Filter-Id[1] == 'foo')) || (!(%{Filter-Id[2]} == 'baz')) || (!(&Filter-Id[3] == 'boink')) || (!(&Filter-Id[4] == 'foo')) || (!(&Filter-Id[5] == 'baz'))) {
test_fail
}
-if (!(%{Tmp-String-0[#]} == 6)) {
+if (!(%{Filter-Id[#]} == 6)) {
test_fail
}
# Set up an attribute in control with a single value
update control {
- &Tmp-String-0 := 'initial'
+ &Filter-Id := 'initial'
}
-# Prepend the list of Tmp-String-0 from request to the new attribute
+# Prepend the list of Filter-Id from request to the new attribute
#update {
-# &control.Tmp-String-0 ^= &Tmp-String-0
+# &control.Filter-Id ^= &Filter-Id
#}
# (Temporary method to achieve the same - as per issue noted above)
}
# The control attributes should now be "wibble", "foo", "baz", "boink", "foo", "baz", "initial"
-if (!((&control.Tmp-String-0[0] == 'wibble')) || (!(&control.Tmp-String-0[1] == 'foo')) || (!(&control.Tmp-String-0[2] == 'baz')) || (!(&control.Tmp-String-0[3] == 'boink')) || (!(&control.Tmp-String-0[4] == 'foo')) || (!(&control.Tmp-String-0[5] == 'baz')) || (!(&control.Tmp-String-0[6] == 'initial'))) {
+if (!((&control.Filter-Id[0] == 'wibble')) || (!(&control.Filter-Id[1] == 'foo')) || (!(&control.Filter-Id[2] == 'baz')) || (!(&control.Filter-Id[3] == 'boink')) || (!(&control.Filter-Id[4] == 'foo')) || (!(&control.Filter-Id[5] == 'baz')) || (!(&control.Filter-Id[6] == 'initial'))) {
test_fail
}
-if (!(%{control.Tmp-String-0[#]} == 7)) {
+if (!(%{control.Filter-Id[#]} == 7)) {
test_fail
}
# PRE: update
#
update {
- &Tmp-String-0 := 'foobarbaz'
- &Tmp-Integer-0 := 123456789
- &Tmp-IP-Address-0 := 192.0.2.1
- &Tmp-IP-Address-0 += 192.0.2.2
- &control.Tmp-IP-Address-0 := 192.0.2.1
- &control.Tmp-IP-Address-0 += 192.0.2.3
- &control.Tmp-IP-Address-1 := 192.0.3.1
+ &Filter-Id := 'foobarbaz'
+ &NAS-Port := 123456789
+ &Framed-IP-Address := 192.0.2.1
+ &Framed-IP-Address += 192.0.2.2
+ &control.Framed-IP-Address := 192.0.2.1
+ &control.Framed-IP-Address += 192.0.2.3
+ &control.Login-IP-Host := 192.0.3.1
}
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.1)) || (!(&Tmp-IP-Address-0[1] == 192.0.2.2))) {
+if (!((&Framed-IP-Address[0] == 192.0.2.1)) || (!(&Framed-IP-Address[1] == 192.0.2.2))) {
test_fail
}
# Remove all attributes in the request list
update {
- &Tmp-IP-Address-0 !* ANY
+ &Framed-IP-Address !* ANY
}
-# Non Tmp-IP-Address-0 address attributes should still be in the request list
-if (!((&Tmp-String-0 == 'foobarbaz')) || (!(&Tmp-Integer-0 == 123456789))) {
+# Non Framed-IP-Address address attributes should still be in the request list
+if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789))) {
test_fail
}
-# There should be no Tmp-IP-Address attributes in the request list
-if (&Tmp-IP-Address-0) {
+# There should be no Framed-IP-Address attributes in the request list
+if (&Framed-IP-Address) {
test_fail
}
# But there should still be some in the control list
-if (!((&control.Tmp-IP-Address-0 == 192.0.2.1)) || (!(&control.Tmp-IP-Address-0[1] == 192.0.2.3))) {
+if (!((&control.Framed-IP-Address == 192.0.2.1)) || (!(&control.Framed-IP-Address[1] == 192.0.2.3))) {
test_fail
}
update {
- &control.Tmp-IP-Address-0 !* ANY
- &control.Tmp-IP-Address-1 !* ANY
+ &control.Framed-IP-Address !* ANY
+ &control.Login-IP-Host !* ANY
}
-if (&control.Tmp-IP-Address-0 || &control.Tmp-IP-Address-1) {
+if (&control.Framed-IP-Address || &control.Login-IP-Host) {
test_fail
}
#
update request {
- &Tmp-String-0 := 'foobarbaz'
- &Tmp-Integer-0 := 123456789
- &Tmp-IP-Address-0 := 192.0.2.1
+ &Filter-Id := 'foobarbaz'
+ &NAS-Port := 123456789
+ &Framed-IP-Address := 192.0.2.1
}
-if (!((&Tmp-String-0 == 'foobarbaz')) || (!(&Tmp-Integer-0 == 123456789)) || (!(&Tmp-IP-Address-0 == 192.0.2.1))) {
+if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789)) || (!(&Framed-IP-Address == 192.0.2.1))) {
test_fail
}
}
# All attributes should now of been removed
-if ((&Tmp-String-0 && (&Tmp-String-0 == 'foobarbaz')) || \
- (&Tmp-Integer-0 && (&Tmp-Integer-0 == 123456789)) || \
- (&Tmp-IP-Address-0 && (&Tmp-IP-Address-0 == 192.0.2.1))) {
+if ((&Filter-Id && (&Filter-Id == 'foobarbaz')) || \
+ (&NAS-Port && (&NAS-Port == 123456789)) || \
+ (&Framed-IP-Address && (&Framed-IP-Address == 192.0.2.1))) {
test_fail
}
#
update {
- &Tmp-String-0 := 'foobarbaz'
- &Tmp-Integer-0 := 123456789
- &Tmp-IP-Address-0 := 192.0.2.1
- &Tmp-IP-Address-0 += 192.0.2.2
- &Tmp-IP-Address-0 += 192.0.2.3
- &Tmp-IP-Address-0 += 192.0.2.4
- &control.Tmp-IP-Address-0 := 192.0.2.1
- &control.Tmp-IP-Address-0 += 192.0.2.3
+ &Filter-Id := 'foobarbaz'
+ &NAS-Port := 123456789
+ &Framed-IP-Address := 192.0.2.1
+ &Framed-IP-Address += 192.0.2.2
+ &Framed-IP-Address += 192.0.2.3
+ &Framed-IP-Address += 192.0.2.4
+ &control.Framed-IP-Address := 192.0.2.1
+ &control.Framed-IP-Address += 192.0.2.3
}
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.1)) || \
- (!(&Tmp-IP-Address-0[1] == 192.0.2.2)) || \
- (!(&Tmp-IP-Address-0[2] == 192.0.2.3)) || \
- (!(&Tmp-IP-Address-0[3] == 192.0.2.4))) {
+if (!((&Framed-IP-Address[0] == 192.0.2.1)) || \
+ (!(&Framed-IP-Address[1] == 192.0.2.2)) || \
+ (!(&Framed-IP-Address[2] == 192.0.2.3)) || \
+ (!(&Framed-IP-Address[3] == 192.0.2.4))) {
test_fail
}
-# Remove Tmp-IP-Address-0 with a specific value
+# Remove Framed-IP-Address with a specific value
update {
- &Tmp-IP-Address-0 -= 192.0.2.1
+ &Framed-IP-Address -= 192.0.2.1
}
-# Only the 2nd, 3rd and 4th Tmp-IP-Address attributes should still be in the list
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.2)) || \
- (!(&Tmp-IP-Address-0[1] == 192.0.2.3)) || \
- (!(&Tmp-IP-Address-0[2] == 192.0.2.4)) || \
- (&Tmp-IP-Address-0[3])) {
+# Only the 2nd, 3rd and 4th Framed-IP-Address attributes should still be in the list
+if (!((&Framed-IP-Address[0] == 192.0.2.2)) || \
+ (!(&Framed-IP-Address[1] == 192.0.2.3)) || \
+ (!(&Framed-IP-Address[2] == 192.0.2.4)) || \
+ (&Framed-IP-Address[3])) {
test_fail
}
-# Remove Tmp-IP-Address-0 with a specific value (somewhere in the middle)
+# Remove Framed-IP-Address with a specific value (somewhere in the middle)
update {
- &Tmp-IP-Address-0 -= 192.0.2.3
+ &Framed-IP-Address -= 192.0.2.3
}
-# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.2)) || \
- (!(&Tmp-IP-Address-0[1] == 192.0.2.4)) || \
- (&Tmp-IP-Address-0[2])) {
+# Only the 1st, and 3rd Framed-IP-Address attributes should still be in the list
+if (!((&Framed-IP-Address[0] == 192.0.2.2)) || \
+ (!(&Framed-IP-Address[1] == 192.0.2.4)) || \
+ (&Framed-IP-Address[2])) {
test_fail
}
-# Remove Tmp-IP-Address-0 with a specific value (which doesn't exist)
+# Remove Framed-IP-Address with a specific value (which doesn't exist)
update {
- &Tmp-IP-Address-0 -= 192.0.2.3
+ &Framed-IP-Address -= 192.0.2.3
}
-# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.2)) || \
- (!(&Tmp-IP-Address-0[1] == 192.0.2.4)) || \
- (&Tmp-IP-Address-0[2])) {
+# Only the 1st, and 3rd Framed-IP-Address attributes should still be in the list
+if (!((&Framed-IP-Address[0] == 192.0.2.2)) || \
+ (!(&Framed-IP-Address[1] == 192.0.2.4)) || \
+ (&Framed-IP-Address[2])) {
test_fail
}
-# Remove Tmp-IP-Address-4 (which doesn't exist - more to check for SEGV/assert)
+# Remove NAS-IP-Address (which doesn't exist - more to check for SEGV/assert)
update {
- &Tmp-IP-Address-4 -= 192.0.2.3
+ &NAS-IP-Address -= 192.0.2.3
}
-# Remove Tmp-IP-Address-0 with a specific value
+# Remove Framed-IP-Address with a specific value
update {
- &Tmp-IP-Address-0 -= 192.0.2.4
+ &Framed-IP-Address -= 192.0.2.4
}
-# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.2)) || \
- (&Tmp-IP-Address-0[1])) {
+# Only the 1st, and 3rd Framed-IP-Address attributes should still be in the list
+if (!((&Framed-IP-Address[0] == 192.0.2.2)) || \
+ (&Framed-IP-Address[1])) {
test_fail
}
-# Remove Tmp-IP-Address-0 with a specific value
+# Remove Framed-IP-Address with a specific value
update {
- &Tmp-IP-Address-0 -= 192.0.2.2
+ &Framed-IP-Address -= 192.0.2.2
}
-# Only the 1st, and 3rd Tmp-IP-Address attributes should still be in the list
-# and the Tmp-IP-Addres-0 attribute should be deleted
-if (&Tmp-IP-Address-0) {
+# Only the 1st, and 3rd Framed-IP-Address attributes should still be in the list
+# and the Framed-IP-Addres-0 attribute should be deleted
+if (&Framed-IP-Address) {
test_fail
}
-# Non Tmp-IP-Address-0 address attributes should still be in the request list
-if (!((&Tmp-String-0 == 'foobarbaz')) || (!(&Tmp-Integer-0 == 123456789))) {
+# Non Framed-IP-Address address attributes should still be in the request list
+if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789))) {
test_fail
}
# But there should still be some in the control list
-if (!((&control.Tmp-IP-Address-0[0] == 192.0.2.1)) || (!(&control.Tmp-IP-Address-0[1] == 192.0.2.3))) {
+if (!((&control.Framed-IP-Address[0] == 192.0.2.1)) || (!(&control.Framed-IP-Address[1] == 192.0.2.3))) {
test_fail
}
-&Tmp-String-0 := "foo"
+&Filter-Id := "foo"
update request {
- &Tmp-String-0 !* ANY
+ &Filter-Id !* ANY
}
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
-&Tmp-String-0 := "foo"
-&reply.Tmp-String-0 := "bar"
+&Filter-Id := "foo"
+&reply.Filter-Id := "bar"
update {
- &request.Tmp-String-0 !* ANY
+ &request.Filter-Id !* ANY
&reply.[*] !* ANY
}
-if (&Tmp-String-0) {
+if (&Filter-Id) {
test_fail
}
-if (&reply.Tmp-String-0) {
+if (&reply.Filter-Id) {
test_fail
}
update reply {
- &Tmp-Integer-0 := 12
+ &NAS-Port := 12
}
-if (!&reply.Tmp-Integer-0) {
+if (!&reply.NAS-Port) {
test_fail
}
update reply {
- &Tmp-Integer-0 += 13
+ &NAS-Port += 13
}
-if (!(&reply.Tmp-Integer-0[0] == 12)) {
+if (!(&reply.NAS-Port[0] == 12)) {
test_fail
}
-if (!(&reply.Tmp-Integer-0[1] == 13)) {
+if (!(&reply.NAS-Port[1] == 13)) {
test_fail
}
#
# PRE: if
#
-&request += {
- # Some encoders replace ~ with %7E RFC3986 Section 2.4 says this should not be done.
- &Tmp-String-0 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~'
- &Tmp-String-2 = '±§!@#$%^&*()+={[}]:;"\'|\<,>?/`'
- &Tmp-String-4 = '™œ¥¤'
- &Tmp-String-6 = '%C2%B1%C2%A7%21%40%23%24%25%5E%26%2A%28%29%2B%3D%7B%5B%7D%5D%3A%3B%22%27%7C%5C%3C%2C%3E%3F%2F%60'
- &Tmp-String-8 = '%E2%84%A2%C5%93%C2%A5%C2%A4'
-}
-
-&request += {
- &Tmp-String-1 = "%urlquote(%{Tmp-String-0})"
- &Tmp-String-3 = "%urlquote(%{Tmp-String-2})"
- &Tmp-String-5 = "%urlquote(%{Tmp-String-4})"
- &Tmp-String-7 = "%urlunquote(%{Tmp-String-6})"
- &Tmp-String-9 = "%urlunquote(%{Tmp-String-8})"
-}
-
-
-if (!(&Tmp-String-1 == &Tmp-String-0)) {
+string test_string1
+string test_string2
+string test_string3
+string encoded_string2
+string encoded_string3
+string result_string
+
+# Some encoders replace ~ with %7E RFC3986 Section 2.4 says this should not be done.
+&test_string1 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~'
+&test_string2 = '±§!@#$%^&*()+={[}]:;"\'|\<,>?/`'
+&test_string3 = '™œ¥¤'
+&encoded_string2 := '%C2%B1%C2%A7%21%40%23%24%25%5E%26%2A%28%29%2B%3D%7B%5B%7D%5D%3A%3B%22%27%7C%5C%3C%2C%3E%3F%2F%60'
+&encoded_string3 := '%E2%84%A2%C5%93%C2%A5%C2%A4'
+
+&result_string = "%urlquote(%{test_string1})"
+if (!(&result_string == &test_string1)) {
test_fail
}
-if (!(&Tmp-String-3 == &Tmp-String-6)) {
+&result_string := "%urlunquote(%{test_string1})"
+if (!(&result_string == &test_string1)) {
test_fail
}
-if (!(&Tmp-String-5 == &Tmp-String-8)) {
+&result_string := "%urlquote(%{test_string2})"
+if (!(&result_string == &encoded_string2)) {
test_fail
}
-if (!(&Tmp-String-7 == &Tmp-String-2)) {
+&result_string := "%urlquote(%{test_string3})"
+if (!(&result_string == &encoded_string3)) {
test_fail
}
-if (!(&Tmp-String-9 == &Tmp-String-4)) {
+&result_string := "%urlunquote(%{encoded_string2})"
+if (!(&result_string == &test_string2)) {
test_fail
}
-&Tmp-String-1 := "%urlunquote(%{Tmp-String-0})"
-
-&request -= &Tmp-String-2[*]
-&Tmp-String-2 := "%urlunquote(%%E,123)"
-
-if (!(&Tmp-String-1 == &Tmp-String-0)) {
+&result_string := "%urlunquote(%{encoded_string3})"
+if (!(&result_string == &test_string3)) {
test_fail
}
+&result_string := "%urlunquote(%%E,123)"
+
# Test decoding invalid encoded string
-if !(&Tmp-String-2 == "") {
+if !(&result_string == "") {
test_fail
}
#
# PRE:
#
+string result_string
-&Tmp-String-0 := "foo"
-&Tmp-String-1 := "bar"
+&Filter-Id := "foo"
+&NAS-Identifier := "bar"
#
# First choice
#
-&Tmp-String-2 := "%{&Tmp-String-0 || &Tmp-String-1}"
-if (!(&Tmp-String-2 == 'foo')) {
+&result_string := "%{&Filter-Id || &NAS-Identifier}"
+if (!(&result_string == 'foo')) {
test_fail
}
#
# Second choice
#
-&request -= &Tmp-String-0[*]
-&Tmp-String-2 := "%{&Tmp-String-0 || &Tmp-String-1}"
-if (!(&Tmp-String-2 == 'bar')) {
+&request -= &Filter-Id[*]
+&result_string := "%{&Filter-Id || &NAS-Identifier}"
+if (!(&result_string == 'bar')) {
test_fail
}
#
# Multiple things in an alternation
#
-&Tmp-String-2 := %{%{Tmp-String-0} || "%{Tmp-String-1} foo"}
-if (!(&Tmp-String-2 == 'bar foo')) {
+&result_string := %{%{Filter-Id} || "%{NAS-Identifier} foo"}
+if (!(&result_string == 'bar foo')) {
test_fail
}
#
# Alternation is empty
#
-&Tmp-String-2 := "%{&Tmp-String-0 || ''}"
-if (!(&Tmp-String-2 == '')) {
+&result_string := "%{&Filter-Id || ''}"
+if (!(&result_string == '')) {
test_fail
}
#
# Everything null
#
-&request -= &Tmp-String-1[*]
-&request -= &Tmp-String-2[*]
+&request -= &NAS-Identifier[*]
#
# Both sides are failing, so the assignment returns a NULL string
#
-&Tmp-String-2 := "%{&Tmp-String-0 || &Tmp-String-1}"
-if (!(&Tmp-String-2 == "")) {
+&result_string := "%{&Filter-Id || &NAS-Identifier}"
+if (!(&result_string == "")) {
test_fail
}
#
# And unquoted results return nothing.
#
-&request -= &Tmp-String-2[*]
-
-&Tmp-String-2 := %{&Tmp-String-0 || &Tmp-String-1}
-if (&Tmp-String-2) {
+&result_string := %{&Filter-Id || &NAS-Identifier}
+if (&result_string) {
test_fail
}
#
# Everything null
#
-&request -= &Tmp-String-0[*]
-&request -= &Tmp-String-1[*]
+string result_string
+&request -= &Filter-Id[*]
+&request -= &NAS-Identifier[*]
-&Tmp-String-2 := "%{&Tmp-String-0[0] || &Tmp-String-1[0]}%delay_10s()"
+&result_string := "%{&Filter-Id[0] || &NAS-Identifier[0]}%delay_10s()"
success
#
# PRE:
#
+string test_string1
+string test_string2
+string dummy_string
-&Tmp-String-0 := "foo"
-&Tmp-String-1 := "bar"
+&test_string1 := "foo"
+&test_string2 := "bar"
-if (!(%{%test.passthrough(%{Tmp-String-0}) || %{Tmp-String-1}} == 'foo')) {
+if (!(%{%test.passthrough(%{test_string1}) || %{test_string2}} == 'foo')) {
test_fail
}
-if (!(%{%test.passthrough(%{Tmp-String-2}) || %{Tmp-String-1}} == 'bar')) {
+if (!(%{%test.passthrough(%{dummy_string}) || %{test_string2}} == 'bar')) {
test_fail
}
-if (!(%{%{Tmp-String-0} || %test.passthrough(%{Tmp-String-1})} == 'foo')) {
+if (!(%{%{test_string1} || %test.passthrough(%{test_string2})} == 'foo')) {
test_fail
}
-if (!(%{%{Tmp-String-2} || %test.passthrough(%{Tmp-String-1})} == 'bar')) {
+if (!(%{%{dummy_string} || %test.passthrough(%{test_string2})} == 'bar')) {
test_fail
}
-if (!(%{%test.passthrough(%{Tmp-String-0}) || %test.passthrough(%{Tmp-String-1})} == 'foo')) {
+if (!(%{%test.passthrough(%{test_string1}) || %test.passthrough(%{test_string2})} == 'foo')) {
test_fail
}
-if (!(%{%test.passthrough(%{Tmp-String-2}) || %test.passthrough(%{Tmp-String-1})} == 'bar')) {
+if (!(%{%test.passthrough(%{dummy_string}) || %test.passthrough(%{test_string2})} == 'bar')) {
test_fail
}
&request += {
- &Tmp-IP-Address-0 = 192.0.2.1
- &Tmp-IP-Address-0 = 192.0.2.2
+ &Framed-IP-Address = 192.0.2.1
+ &Framed-IP-Address = 192.0.2.2
}
-if (!(%{Tmp-IP-Address-0[#]} == 2)) {
+if (!(%{Framed-IP-Address[#]} == 2)) {
test_fail
}
-if (!((&Tmp-IP-Address-0[0] == 192.0.2.1)) || (!(&Tmp-IP-Address-0[1] == 192.0.2.2))) {
+if (!((&Framed-IP-Address[0] == 192.0.2.1)) || (!(&Framed-IP-Address[1] == 192.0.2.2))) {
test_fail
}
-if (!("%{Tmp-IP-Address-0[*]}" == '192.0.2.1192.0.2.2')) {
+if (!("%{Framed-IP-Address[*]}" == '192.0.2.1192.0.2.2')) {
test_fail
}
# Try calling these xlats in mapping too, they may get optimised to VPTs which is a
# different code path.
&request += {
- &Tmp-IP-Address-1 = &Tmp-IP-Address-0[1]
- &Tmp-IP-Address-1 = &Tmp-IP-Address-0[0]
- &Tmp-String-0 = "%concat(%{Tmp-IP-Address-0[*]}, ',')"
- &Tmp-Integer-0 = %{Tmp-IP-Address-0[#]}
+ &NAS-IP-Address = &Framed-IP-Address[1]
+ &NAS-IP-Address = &Framed-IP-Address[0]
+ &Filter-Id = "%concat(%{Framed-IP-Address[*]}, ',')"
+ &NAS-Port = %{Framed-IP-Address[#]}
}
-if (!(&Tmp-String-0 == '192.0.2.1,192.0.2.2')) {
+if (!(&Filter-Id == '192.0.2.1,192.0.2.2')) {
test_fail
}
-if (!(&Tmp-Integer-0 == 2)) {
+if (!(&NAS-Port == 2)) {
test_fail
}
&request += {
- &Tmp-IP-Address-0 = 192.0.2.1
- &Tmp-IP-Address-0 = 192.0.2.2
- &Tmp-IP-Address-0 = 192.0.2.3
- &Tmp-IP-Address-0 = 192.0.2.4
+ &Framed-IP-Address = 192.0.2.1
+ &Framed-IP-Address = 192.0.2.2
+ &Framed-IP-Address = 192.0.2.3
+ &Framed-IP-Address = 192.0.2.4
}
-if (%{Tmp-IP-Address-0[#]} != 4) {
+if (%{Framed-IP-Address[#]} != 4) {
test_fail
}
# for the existence of the attribute. But... the syntax allows it, so
# it should work.
#
-if !("%{Tmp-IP-Address-0[4]}" == '') {
+if !("%{Framed-IP-Address[4]}" == '') {
test_fail
}
#
# PRE: if
#
+string result_string
+uint32 result_integer
-&Tmp-String-0 := "%config(modules.test.boolean)"
-if (!(&Tmp-String-0 == "no")) {
+&result_string := "%config(modules.test.boolean)"
+if (!(&result_string == "no")) {
test_fail
}
-&Tmp-String-0 := "test"
-&Tmp-Integer-0 := %config(modules.%{Tmp-String-0}.integer)
-if (!(&Tmp-Integer-0 == 1)) {
+&result_string := "test"
+&result_integer := %config(modules.%{result_string}.integer)
+if (!(&result_integer == 1)) {
test_fail
}
-success
\ No newline at end of file
+success
#
# PRE: update
#
+float32 result_float
# This is mainly a smoke test... i.e. if it crashes there's smoke
%delay_10s() # Should 'blip' the request
-&Tmp-Float-0 := %delay_10s(0.1)
-if (!&Tmp-Float-0) {
+&result_float := %delay_10s(0.1)
+if (!&result_float) {
fail
}
#
# Check the delay was ~100ms
#
-if (&Tmp-Float-0 < 0.1) {
+if (&result_float < 0.1) {
fail
}
#
# PROTOCOL: dhcpv4
#
+octets test_octets
-&Tmp-Octets-0 := 0x520d0103abcdef0206010203040506
+&test_octets := 0x520d0103abcdef0206010203040506
# the protocol decoder puts the attributes into a flat namespace
-if (!(%dhcpv4.decode(%{Tmp-Octets-0}) == 1)) {
+if (!(%dhcpv4.decode(%{test_octets}) == 1)) {
test_fail
}
#
# Encode all of the Relay-Agent-Information suboptions
#
-&Tmp-Octets-1 := %dhcpv4.encode(&request.Relay-Agent-Information.[*])
+&test_octets := %dhcpv4.encode(&request.Relay-Agent-Information.[*])
-if !(&Tmp-Octets-1 == 0x520d0103abcdef0206010203040506) {
+if !(&test_octets == 0x520d0103abcdef0206010203040506) {
test_fail
}
# Regression test for double consecutive alternations
-&Tmp-uint64-0 := "%{&Acct-Input-Octets || "2"}%{&Acct-Input-Gigawords || "1"}"
-if (!(&Tmp-uint64-0 == 21)) {
+uint64 result_int64
+
+&result_int64 := "%{&Acct-Input-Octets || "2"}%{&Acct-Input-Gigawords || "1"}"
+if (!(&result_int64 == 21)) {
test_fail
}
&request += {
- &Tmp-String-1 = 'foo'
- &Tmp-String-1 = 'bar'
- &Tmp-Integer-0 = '4'
- &Tmp-Integer-0 = '8'
- &Tmp-Integer-0 = '1'
+ &Filter-Id = 'foo'
+ &Filter-Id = 'bar'
+ &NAS-Port = '4'
+ &NAS-Port = '8'
+ &NAS-Port = '1'
- &Tmp-String-0 = '%{Tmp-String-1}'
+ &Reply-Message = '%{Filter-Id}'
}
#
# Verify non string types are treated as literals
#
-if (!("%eval(%{Tmp-Integer-0})" == 4)) {
+if (!("%eval(%{NAS-Port})" == 4)) {
test_fail
}
-if (!(%eval(%{Tmp-Integer-0[1]}) == 8)) {
+if (!(%eval(%{NAS-Port[1]}) == 8)) {
test_fail
}
#
# Check double expansion works
#
-if (!(%eval(%{Tmp-String-0}) == 'foo')) {
+if (!(%eval(%{Reply-Message}) == 'foo')) {
test_fail
}
#
# Using an attribute as a dynamic index for another attribute
#
-if (!(%eval("\%{Tmp-String-1[%{Tmp-Integer-0[2]}]}") == 'bar')) {
+if (!(%eval("\%{Filter-Id[%{NAS-Port[2]}]}") == 'bar')) {
test_fail
}
&idx := 1
- if (!(%eval("\%{Tmp-String-1[%{idx}]}") == 'bar')) {
+ if (!(%eval("\%{Filter-Id[%{idx}]}") == 'bar')) {
test_fail
}
-&Tmp-String-0 = "foo"
-&Tmp-String-1 := %exec('/bin/echo', "hello 1234:%{Tmp-String-0} world")
+string test_string
+string result_string
-if (!(&Tmp-String-1 == "hello 1234:foo world")) {
+&test_string = "foo"
+&result_string := %exec('/bin/echo', "hello 1234:%{test_string} world")
+
+if (!(&result_string == "hello 1234:foo world")) {
test_fail
}
-&Tmp-String-1 := %exec('/bin/echo', "hello %{Tmp-String-0}:1234 world")
-if (!(&Tmp-String-1 == "hello foo:1234 world")) {
+&result_string := %exec('/bin/echo', "hello %{test_string}:1234 world")
+if (!(&result_string == "hello foo:1234 world")) {
test_fail
}
# User-Password contains characters that need escaping
-&Tmp-String-2 := %exec('/bin/echo', "%{User-Password}")
-if (!(&Tmp-String-2 == &User-Password)) {
+&result_string := %exec('/bin/echo', "%{User-Password}")
+if (!(&result_string == &User-Password)) {
test_fail
} else {
&User-Password := "hello"
#
# Check explode works correctly
#
+string result_string
+
&request += {
&Class = '1=1|my_attr=2|my_attr=hello|'
&Calling-Station-ID = '|'
&User-Name = '|hello|goodbye'
&User-Name = '|morning|night|1|'
&Reply-Message = 'Can\'t touch this'
- &Tmp-String-0 = 'here. are . some. words. '
+ &Filter-Id = 'here. are . some. words. '
}
-&request += {
- &Tmp-String-1 = "%concat(%explode(%{Class}, '|'), ',')"
- &Tmp-String-2 = "%concat(%explode(%{Calling-Station-ID}, '|'), ',')"
- &Tmp-String-3 = "%concat(%explode(%{control.User-Name[*]}, |), ',')"
- &Tmp-String-4 = "%concat(%explode(%{control.Reply-Message}, |), ',')"
- &Tmp-String-5 = "%concat(%explode(%{control.Tmp-String-0}, '. '), ',')"
-}
-
-debug_all
-
-if (!(&Tmp-String-1 == "1=1,my_attr=2,my_attr=hello")) {
+&result_string := "%concat(%explode(%{Class}, '|'), ',')"
+if (!(&result_string == "1=1,my_attr=2,my_attr=hello")) {
test_fail
}
-if (!(&Tmp-String-2 == "")) {
+&result_string := "%concat(%explode(%{Calling-Station-ID}, '|'), ',')"
+if (!(&result_string == "")) {
test_fail
}
-if (!(&Tmp-String-3 == "hello,goodbye,morning,night,1")) {
+&result_string := "%concat(%explode(%{control.User-Name[*]}, |), ',')"
+if (!(&result_string == "hello,goodbye,morning,night,1")) {
test_fail
}
-if !(&Tmp-String-4 == 'Can\'t touch this') {
+&result_string := "%concat(%explode(%{control.Reply-Message}, |), ',')"
+if !(&result_string == 'Can\'t touch this') {
test_fail
}
-if !(&Tmp-String-5 == 'here, are ,some, words') {
+&result_string := "%concat(%explode(%{control.Filter-Id}, '. '), ',')"
+if !(&result_string == 'here, are ,some, words') {
test_fail
}
# Set debug to something high, recording the old level
-&Tmp-Integer-0 := "%debug(4)"
+uint32 test_integer
+
+&test_integer := %debug(4)
# Check debug level is now 4
-if (!("%debug(4)" == 4)) {
+if (!(%debug(4) == 4)) {
test_fail
}
# Set debug back to the original level
-"%debug(%{Tmp-Integer-0})"
+%debug(%{test_integer})
# Read out the current debug level to verify it changed
-if (!("%debug(%{Tmp-Integer-0})" == "%{Tmp-Integer-0}")) {
+if (!(%debug(%{test_integer}) == "%{test_integer}")) {
test_fail
}
# Note the test for %interpreter(.line) is sensitive to the position of the
# instruction we're running.
#
+string result_string
+uint32 result_integer
-&Tmp-String-0 := "%interpreter(.filename)"
-&Tmp-Integer-0 := "%interpreter(.line)"
-&Tmp-String-1 := "%interpreter(.name)"
-&Tmp-String-2 := "%interpreter(.type)"
+&result_string := "%interpreter(.filename)"
+&result_integer := "%interpreter(.line)"
-if (!(&Tmp-String-0 == "src/tests/keywords/xlat-interpreter")) {
+if (!(&result_string == "src/tests/keywords/xlat-interpreter")) {
test_fail
}
-if (!(&Tmp-String-1 == "&Tmp-String-1")) {
+&result_string := "%interpreter(.name)"
+if (!(&result_string == "&result_string")) {
test_fail
}
-if (!(&Tmp-String-2 == "edit")) {
+&result_string := "%interpreter(.type)"
+if (!(&result_string == "edit")) {
test_fail
}
-if (!(&Tmp-Integer-0 == 9)) {
+if (!(&result_integer == 11)) {
test_fail
}
&control := {
- &Tmp-IP-Address-0 = 192.0.2.1
- &Tmp-IP-Address-0 = 192.0.2.2
+ &Framed-IP-Address = 192.0.2.1
+ &Framed-IP-Address = 192.0.2.2
}
if !(%{control.[#]} == 2) {
# Try calling these xlats in mapping too, they may get optimised to VPTs which is a
# different code path.
&request += {
- &Tmp-IP-Address-1 = %{control.[1]}
- &Tmp-IP-Address-1 = %{control.[0]}
- &Tmp-String-0 = %concat(%{control.[*]}, ',')
- &Tmp-Integer-0 = %{control.[#]}
+ &NAS-IP-Address = %{control.[1]}
+ &NAS-IP-Address = %{control.[0]}
+ &Filter-Id = %concat(%{control.[*]}, ',')
+ &NAS-Port = %{control.[#]}
}
-if !(&Tmp-String-0 == '192.0.2.1,192.0.2.2') {
+if !(&Filter-Id == '192.0.2.1,192.0.2.2') {
test_fail
}
-if !(&Tmp-Integer-0 == 2) {
+if !(&NAS-Port == 2) {
test_fail
}
# octet strings must NOT have a 0x prefix added
#
&request += {
- &Tmp-Octets-0 = 0x0001020304050607
- &Tmp-Octets-0 = 0x0706050403020100
+ &Class = 0x0001020304050607
+ &Class = 0x0706050403020100
}
-if (!(&Tmp-Octets-0 == 0x0001020304050607)) {
+if (!(&Class == 0x0001020304050607)) {
test_fail
}
-if (!(&Tmp-Octets-0[0] == 0x0001020304050607)) {
+if (!(&Class[0] == 0x0001020304050607)) {
test_fail
}
-if (!("%{Tmp-Octets-0[*]}" == 0x00010203040506070706050403020100)) {
+if (!("%{Class[*]}" == 0x00010203040506070706050403020100)) {
test_fail
}
#
# PRE: if
#
-&request += {
- &Tmp-Octets-0 = 0x5c5c
- &Tmp-Octets-1 = 0x49206c696b6520636869636b656e2049206c696b65206c69766572
- &Tmp-Octets-2 = 0x490049
- &Tmp-Octets-3 = 0x00
- &Tmp-Octets-4 = 0x7465737431
- &Tmp-Octets-5 = 0x7465737432
-}
+octets test_octets1
+octets test_octets2
+octets test_octets3
+octets test_octets4
+octets test_octets5
+octets test_octets6
+string result_string
-&request += {
- &Tmp-String-0 = %{(string) %{Tmp-Octets-0}}
- &Tmp-String-1 = %{(string) %{Tmp-Octets-1}}
- &Tmp-String-2 = %{(string) %{Tmp-Octets-2}}
- &Tmp-String-3 = %{(string) %{Tmp-Octets-3}}
-}
+&test_octets1 := 0x5c5c
+&test_octets2 := 0x49206c696b6520636869636b656e2049206c696b65206c69766572
+&test_octets3 := 0x490049
+&test_octets4 = 0x00
+&test_octets5 = 0x7465737431
+&test_octets6 = 0x7465737432
-if (!(&Tmp-String-0 == "\\\\")) {
+&result_string := %{(string) %{test_octets1}}
+if (!(&result_string == "\\\\")) {
test_fail
}
#
# Test interpolation between string expansions and strings
#
-if (!("%{(string) %{Tmp-Octets-4}}%{(string) %{Tmp-Octets-5}}" == "test1test2")) {
+if (!("%{(string) %{test_octets5}}%{(string) %{test_octets6}}" == "test1test2")) {
test_fail
}
#
# convert to string and then concatenate
#
-if (!(%{(string) %{Tmp-Octets-4}} + %{(string) %{Tmp-Octets-5}} == "test1test2")) {
+if (!(%{(string) %{test_octets5}} + %{(string) %{test_octets6}} == "test1test2")) {
test_fail
}
#
# concatenate, and then convert to string
#
-if (!(%{(string) (%{Tmp-Octets-4} + %{Tmp-Octets-5})} == "test1test2")) {
+if (!(%{(string) (%{test_octets5} + %{test_octets6})} == "test1test2")) {
test_fail
}
#
# We don't need %{(string) ...) either.
#
-if !("%{(string) &Tmp-Octets-4}%{(string) &Tmp-Octets-5}" == "test1test2") {
+if !("%{(string) &test_octets5}%{(string) &test_octets6}" == "test1test2") {
test_fail
}
-if (!("test0%{(string) %{Tmp-Octets-4}}%{(string) %{Tmp-Octets-5}}" == "test0test1test2")) {
+if (!("test0%{(string) %{test_octets5}}%{(string) %{test_octets6}}" == "test0test1test2")) {
test_fail
}
-if (!("%{(string) %{Tmp-Octets-4}}%{(string) %{Tmp-Octets-5}}test3" == "test1test2test3")) {
+if (!("%{(string) %{test_octets5}}%{(string) %{test_octets6}}test3" == "test1test2test3")) {
test_fail
}
-if !(&Tmp-String-1 == 'I like chicken I like liver') {
+&result_string := %{(string) %{test_octets2}}
+if !(&result_string == 'I like chicken I like liver') {
test_fail
}
-if (!(&Tmp-String-2 == "I\000I")) {
+&result_string := %{(string) %{test_octets3}}
+if (!(&result_string == "I\000I")) {
test_fail
}
-if (!(&Tmp-String-3 == "\000")) {
+&result_string := %{(string) %{test_octets4}}
+if (!(&result_string == "\000")) {
test_fail
}
-&Tmp-String-0 := 'aaa'
-&Tmp-String-1 := "\n\n\n"
-&Tmp-String-2 := "the quick brown fox jumped over the lazy dog"
+string test_string1
+string test_string2
+string test_string3
+
+&test_string1 := 'aaa'
+&test_string2 := "\n\n\n"
+&test_string3 := "the quick brown fox jumped over the lazy dog"
#
# Non-regex base substitutions
#
# Global substitution
-if (!(%subst(%{Tmp-String-0}, 'a', 'b') == 'bbb')) {
+if (!(%subst(%{test_string1}, 'a', 'b') == 'bbb')) {
test_fail
}
# No match
-if (!(%subst(%{Tmp-String-0}, 'c', 'b') == 'aaa')) {
+if (!(%subst(%{test_string1}, 'c', 'b') == 'aaa')) {
test_fail
}
# Line ending rewrite
-if (!(%subst(%{Tmp-String-1}, "\n", "\r") == "\r\r\r")) {
+if (!(%subst(%{test_string2}, "\n", "\r") == "\r\r\r")) {
test_fail
}
# Removal
-if (!(%subst(%{Tmp-String-0}, 'a', '') == "")) {
+if (!(%subst(%{test_string1}, 'a', '') == "")) {
test_fail
}
# Removal of last word only
-if (!(%subst(%{Tmp-String-2}, 'dog', '') == "the quick brown fox jumped over the lazy ")) {
+if (!(%subst(%{test_string3}, 'dog', '') == "the quick brown fox jumped over the lazy ")) {
test_fail
}
# Removal of first and subsequent word
-if (!(%subst(%{Tmp-String-2}, 'the', '') == " quick brown fox jumped over lazy dog")) {
+if (!(%subst(%{test_string3}, 'the', '') == " quick brown fox jumped over lazy dog")) {
test_fail
}
# Removal of middle word
-if (!(%subst(%{Tmp-String-2}, 'jumped', '') == "the quick brown fox over the lazy dog")) {
+if (!(%subst(%{test_string3}, 'jumped', '') == "the quick brown fox over the lazy dog")) {
test_fail
}
# Replacement of last word only
-if (!(%subst(%{Tmp-String-2}, 'dog', 'cat') == "the quick brown fox jumped over the lazy cat")) {
+if (!(%subst(%{test_string3}, 'dog', 'cat') == "the quick brown fox jumped over the lazy cat")) {
test_fail
}
# Replacement of first and subsequent word
-if (!(%subst(%{Tmp-String-2}, 'the', 'cat') == "cat quick brown fox jumped over cat lazy dog")) {
+if (!(%subst(%{test_string3}, 'the', 'cat') == "cat quick brown fox jumped over cat lazy dog")) {
test_fail
}
# Replacement of middle word
-if (!(%subst(%{Tmp-String-2}, 'jumped', 'cat') == "the quick brown fox cat over the lazy dog")) {
+if (!(%subst(%{test_string3}, 'jumped', 'cat') == "the quick brown fox cat over the lazy dog")) {
test_fail
}
if ("${feature.regex-pcre2}" == 'yes') {
# Basic substitutions
-if (!(%subst(%{Tmp-String-0}, /a/, 'b') == 'baa')) {
+if (!(%subst(%{test_string1}, /a/, 'b') == 'baa')) {
test_fail
}
# Global substitution
-if (!(%subst(%{Tmp-String-0}, /a/g, 'b') == 'bbb')) {
+if (!(%subst(%{test_string1}, /a/g, 'b') == 'bbb')) {
test_fail
}
# No match
-if (!(%subst(%{Tmp-String-0}, /z/, 'b') == 'aaa')) {
+if (!(%subst(%{test_string1}, /z/, 'b') == 'aaa')) {
test_fail
}
#
# Check that newlines really are newlines
-if (!(%length(%{Tmp-String-1}) == 3)) {
+if (!(%length(%{test_string2}) == 3)) {
test_fail
}
# Strip out just the first newline
-if (!(%subst(%{Tmp-String-1}, /^./s, '') == "\n\n")) {
+if (!(%subst(%{test_string2}, /^./s, '') == "\n\n")) {
test_fail
}
-if (!(%subst(%{Tmp-String-1}, /\n/, '') == "\n\n")) {
+if (!(%subst(%{test_string2}, /\n/, '') == "\n\n")) {
test_fail
}
# Strip out all the newlines
-if (!(%subst(%{Tmp-String-1}, /\n/g, '') == '')) {
+if (!(%subst(%{test_string2}, /\n/g, '') == '')) {
test_fail
}
# Line ending switch
-if (!(%subst(%{Tmp-String-1}, /\n/g, "\r") == "\r\r\r")) {
+if (!(%subst(%{test_string2}, /\n/g, "\r") == "\r\r\r")) {
test_fail
}
# Bad regex
-if (%subst(%{Tmp-String-0}, /***/g, '.')) {
+if (%subst(%{test_string1}, /***/g, '.')) {
test_fail
}
&request -= &Module-Failure-Message[*]
# Empty regex
-if (%subst(%{Tmp-String-0}, //g, '.')) {
+if (%subst(%{test_string1}, //g, '.')) {
test_fail
}