that's the result of a lot of work.
string result_string1
string result_string2
-&Vendor-Specific.3GPP.IMSI := "hello"
+Vendor-Specific.3GPP.IMSI := "hello"
#
# "request.[0-9]" should be parsed as a list followed
# by an attribute.
#
-&result_string1 := &Vendor-Specific.3GPP.IMSI
-&result_string2 := &request.Vendor-Specific.3GPP.IMSI
+result_string1 := Vendor-Specific.3GPP.IMSI
+result_string2 := request.Vendor-Specific.3GPP.IMSI
success
# Test the acct_unique policy
#
#
-&Acct-Unique-Session-Id := %hex(%md5("%{User-Name},%{Acct-Multi-Session-ID},%{Acct-Session-ID},%{&NAS-IPv6-Address || &NAS-IP-Address},%{NAS-Identifier},%{NAS-Port-ID},%{NAS-Port}"))
+Acct-Unique-Session-Id := %hex(%md5("%{User-Name},%{Acct-Multi-Session-ID},%{Acct-Session-ID},%{NAS-IPv6-Address || NAS-IP-Address},%{NAS-Identifier},%{NAS-Port-ID},%{NAS-Port}"))
-if &Acct-Unique-Session-Id != "159dccf021583d7413b0114a090529ca" {
+if Acct-Unique-Session-Id != "159dccf021583d7413b0114a090529ca" {
test_fail
}
# We're not running the 'pap' module, so
# we have to set this ourselves.
#
- &control.Auth-Type := ::pap
+ control.Auth-Type := ::pap
# not at the end of a section
actions { # ERROR
# We're not running the 'pap' module, so
# we have to set this ourselves.
#
- &control.Auth-Type := ::pap
+ control.Auth-Type := ::pap
actions {
ok = return
-&Vendor-Specific.WiMAX.Capability.Release := "foo"
+Vendor-Specific.WiMAX.Capability.Release := "foo"
#
# WiMAX is an alias to Vendor-Specific.WiMAX
#
-if !(&request.WiMAX.Capability.Release == "foo") {
+if !(request.WiMAX.Capability.Release == "foo") {
test_fail
}
# @todo - set "-S require_enum_prefix=yes" here, so that the flag is set _before_ we read the config files.
#
$(OUTPUT)/%: $(DIR)/% $(TEST_BIN_DIR)/unit_test_module | $(KEYWORD_RADDB) $(KEYWORD_LIBS) build.raddb rlm_test.la rlm_csv.la rlm_unpack.la
- $(eval CMD:=KEYWORD=$(notdir $@) $(TEST_BIN)/unit_test_module $(NEW_COND) $(UNIT_TEST_KEYWORD_ARGS.$(subst -,_,$(notdir $@))) -D share/dictionary -d src/tests/keywords/ -i "$@.attrs" -f "$@.attrs" -r "$@" -xx $(KEYWORD_OPTS))
+ $(eval CMD:=KEYWORD=$(notdir $@) $(TEST_BIN)/unit_test_module $(NEW_COND) $(UNIT_TEST_KEYWORD_ARGS.$(subst -,_,$(notdir $@))) -D share/dictionary -d src/tests/keywords/ -i "$@.attrs" -f "$@.attrs" -r "$@" -S require_enum_prefix=yes -xx )
@echo "KEYWORD-TEST $(notdir $@)"
${Q}if ! $(CMD) > "$@.log" 2>&1 || ! test -f "$@"; then \
if ! grep ERROR $< 2>&1 > /dev/null; then \
-&request.Acct-Unique-Session-Id := %hex(%md5("%{User-Name},%{Acct-Multi-Session-ID},%{Acct-Session-ID},%{%{NAS-IPv6-Address}:-%{NAS-IP-Address}},%{NAS-Identifier},%{NAS-Port-ID},%{NAS-Port}")) # ERROR
+request.Acct-Unique-Session-Id := %hex(%md5("%{User-Name},%{Acct-Multi-Session-ID},%{Acct-Session-ID},%{%{NAS-IPv6-Address}:-%{NAS-IP-Address}},%{NAS-Identifier},%{NAS-Port-ID},%{NAS-Port}")) # ERROR
#
# Tests for dereferencing the Nth attribute
#
-&request += {
- &Class = 0x01020304,
- &Class = 0x05060708,
- &Class = 0x090a0b0c,
+request += {
+ Class = 0x01020304,
+ Class = 0x05060708,
+ Class = 0x090a0b0c,
}
if (!(%{Class[#]} == 3)) {
test_fail
}
-if (!(&Class[0] == 0x01020304)) {
+if (!(Class[0] == 0x01020304)) {
test_fail
}
-if (!(&Class[1] == 0x05060708)) {
+if (!(Class[1] == 0x05060708)) {
test_fail
}
-if (!(&Class[2] == 0x090a0b0c)) {
+if (!(Class[2] == 0x090a0b0c)) {
test_fail
}
# must not exist
-if (&Class[3]) {
+if (Class[3]) {
test_fail
}
# Last element of the array
-if (!(&Class[n] == 0x090a0b0c)) {
+if (!(Class[n] == 0x090a0b0c)) {
test_fail
}
#
# We might allow this later. But for now, the code doesn't implement it, so we don't allow it.
#
-&User-Name[*] = "foo" # ERROR
+User-Name[*] = "foo" # ERROR
-&request += {
- &Filter-Id = "foo"
- &Filter-Id = "bar"
- &Filter-Id = "baz"
+request += {
+ Filter-Id = "foo"
+ Filter-Id = "bar"
+ Filter-Id = "baz"
}
-&Filter-Id[1] := "yellow"
+Filter-Id[1] := "yellow"
if (!("%{Filter-Id[*]}" == "fooyellowbaz")) {
test_fail
}
-&Filter-Id[2] += "red"
+Filter-Id[2] += "red"
if (!("%{Filter-Id[*]}" == "fooyellowbazred")) {
test_fail
}
-&Filter-Id[2] -= "red"
+Filter-Id[2] -= "red"
if (!("%{Filter-Id[*]}" == "fooyellowbaz")) {
test_fail
}
-&Filter-Id[0] := "oof"
+Filter-Id[0] := "oof"
if (!("%{Filter-Id[*]}" == "oofyellowbaz")) {
test_fail
}
-&Filter-Id[1] := "bar"
+Filter-Id[1] := "bar"
if (!("%{Filter-Id[*]}" == "oofbarbaz")) {
test_fail
}
#
uint32 index
-&request += {
- &Class = 0x01020304,
- &Class = 0x05060708,
- &Class = 0x090a0b0c,
+request += {
+ Class = 0x01020304,
+ Class = 0x05060708,
+ Class = 0x090a0b0c,
}
#
# Computed indexes, with some limitations
#
-&index := 1
+index := 1
-if (&Class[%{&index - 1}] != 0x01020304) {
+if (Class[%{index - 1}] != 0x01020304) {
test_fail
}
-&index := 4
+index := 4
-if (&Class[%{&index - 2}] != 0x090a0b0c) {
+if (Class[%{index - 2}] != 0x090a0b0c) {
test_fail
}
#
# PRE: attr-index
#
-# Tests for using attribute references as array &index
+# Tests for using attribute references as array index
#
uint32 index
-&request += {
- &Class = 0x01020304,
- &Class = 0x05060708,
- &Class = 0x090a0b0c,
+request += {
+ Class = 0x01020304,
+ Class = 0x05060708,
+ Class = 0x090a0b0c,
}
-&index := 1
+index := 1
-if (&Class[&index] != 0x05060708) {
+if (Class[index] != 0x05060708) {
test_fail
}
-&index := 0
+index := 0
-if (&Class[&index] != 0x01020304) {
+if (Class[index] != 0x01020304) {
test_fail
}
-&index := 2
+index := 2
-if (&Class[&index] != 0x090a0b0c) {
+if (Class[index] != 0x090a0b0c) {
test_fail
}
#
# This one doesn't exist.
#
-&index := 3
+index := 3
-if (&Class[&index]) {
+if (Class[index]) {
test_fail
}
uint64 test_int64
ipv4prefix test_ipv4prefix
-&test_string = '9870'
-&test_octets = 0x39383731
-&test_ipaddr = 57.56.55.50
-&test_int = 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
+test_string = '9870'
+test_octets = 0x39383731
+test_ipaddr = 57.56.55.50
+test_int = 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
-&test_output := %base64.encode(%{test_string})
-if (!(&test_output == 'OTg3MA==')) {
+test_output := %base64.encode(%{test_string})
+if (!(test_output == 'OTg3MA==')) {
test_fail
}
# Octets - bin 0x39383731
-&test_output := %base64.encode(%{test_octets})
-if (!(&test_output == 'OTg3MQ==')) {
+test_output := %base64.encode(%{test_octets})
+if (!(test_output == 'OTg3MQ==')) {
test_fail
}
# IP Address - bin 0x39383732
-&test_output := %base64.encode(%{test_ipaddr})
-if (!(&test_output == 'OTg3Mg==')) {
+test_output := %base64.encode(%{test_ipaddr})
+if (!(test_output == 'OTg3Mg==')) {
test_fail
}
# Integer - bin 0x39383734
-&test_output := %base64.encode(%{test_int})
-if (!(&test_output == 'OTg3NA==')) {
+test_output := %base64.encode(%{test_int})
+if (!(test_output == 'OTg3NA==')) {
test_fail
}
# ifid - bin 0x0000000039383737
-&test_output := %base64.encode(%{test_ifid})
-if (!(&test_output == 'AAAAADk4Nzc=')) {
+test_output := %base64.encode(%{test_ifid})
+if (!(test_output == 'AAAAADk4Nzc=')) {
test_fail
}
# ipv6addr - bin 0x00000000000000000000000039383738
-&test_output := %base64.encode(%{test_ipv6addr})
-if (!(&test_output == 'AAAAAAAAAAAAAAAAOTg3OA==')) {
+test_output := %base64.encode(%{test_ipv6addr})
+if (!(test_output == 'AAAAAAAAAAAAAAAAOTg3OA==')) {
test_fail
}
# ipv6addrprefix - bin 0x008000000000000000000000000039383739
-&test_output := %base64.encode(%{test_ipv6prefix})
-if (!(&test_output == 'AIAAAAAAAAAAAAAAAAA5ODc5')) {
+test_output := %base64.encode(%{test_ipv6prefix})
+if (!(test_output == 'AIAAAAAAAAAAAAAAAAA5ODc5')) {
test_fail
}
# byte - bin 0x3a
-&test_output := %base64.encode(%{test_byte})
-if (!(&test_output == 'Og==')) {
+test_output := %base64.encode(%{test_byte})
+if (!(test_output == 'Og==')) {
test_fail
}
# short - bin 0x373b
-&test_output := %base64.encode(%{test_short})
-if (!(&test_output == 'Nzs=')) {
+test_output := %base64.encode(%{test_short})
+if (!(test_output == 'Nzs=')) {
test_fail
}
# ethernet - bin 0x00003938373c
-&test_output := %base64.encode(%{test_ether})
-if (!(&test_output == 'AAA5ODc8')) {
+test_output := %base64.encode(%{test_ether})
+if (!(test_output == 'AAA5ODc8')) {
test_fail
}
# integer64 - bin 0x100000003938373d
-&test_output := %base64.encode(%{test_int64})
-if (!(&test_output == 'EAAAADk4Nz0=')) {
+test_output := %base64.encode(%{test_int64})
+if (!(test_output == 'EAAAADk4Nz0=')) {
test_fail
}
# ipv4prefix - bin 0x203938373e
-&test_output := %base64.encode(%{test_ipv4prefix})
-if (!(&test_output == 'IDk4Nz4=')) {
+test_output := %base64.encode(%{test_ipv4prefix})
+if (!(test_output == 'IDk4Nz4=')) {
test_fail
}
# Something weird causes this test not to parse
-# &test_octets := %base64.decode("")
-#if (!(&test_octets == "")) {
+# test_octets := %base64.decode("")
+#if (!(test_octets == "")) {
# test_fail
#}
# Regression test, this used to crash...
-&test_octets := %base64.decode(Zm9v)
-if (!(&test_octets == "foo")) {
+test_octets := %base64.decode(Zm9v)
+if (!(test_octets == "foo")) {
debug_request
test_fail
}
-&test_octets := %base64.decode(AIAAAAAAAAAAAAAAAAA5ODc5)
-if (!(&test_octets == 0x008000000000000000000000000039383739)) {
+test_octets := %base64.decode(AIAAAAAAAAAAAAAAAAA5ODc5)
+if (!(test_octets == 0x008000000000000000000000000039383739)) {
test_fail
}
# Regression tests
-&test_octets := %base64.decode(5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK)
+test_octets := %base64.decode(5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK)
-if (!(&test_octets == 0xe5136a365f2260b6e409cec9851f1ab384ed0c3097ea8b6eb96b5c8daf2b213532c7dceb9c749ef6d4c71a628a)) {
+if (!(test_octets == 0xe5136a365f2260b6e409cec9851f1ab384ed0c3097ea8b6eb96b5c8daf2b213532c7dceb9c749ef6d4c71a628a)) {
test_fail
}
-&test_octets := %base64.decode(eHfXPKZ+2iv9cnMV1MOmE/moYYA1Uk5xTmw4aVlMYmtDYzdKaFI4YXM0VHRERENYNm90dXVXdGNqYThySVRVeXg5enJuSFNlOXRUSEdtS0s=)
+test_octets := %base64.decode(eHfXPKZ+2iv9cnMV1MOmE/moYYA1Uk5xTmw4aVlMYmtDYzdKaFI4YXM0VHRERENYNm90dXVXdGNqYThySVRVeXg5enJuSFNlOXRUSEdtS0s=)
-if (!(&test_octets == 0x7877d73ca67eda2bfd727315d4c3a613f9a8618035524e714e6c3869594c626b4363374a685238617334547444444358366f7475755774636a6138724954557978397a726e48536539745448476d4b4b)) {
+if (!(test_octets == 0x7877d73ca67eda2bfd727315d4c3a613f9a8618035524e714e6c3869594c626b4363374a685238617334547444444358366f7475755774636a6138724954557978397a726e48536539745448476d4b4b)) {
test_fail
}
success
#
octets result_octets
-&result_octets := %bin('39383730')
-if !(&result_octets == 0x39383730) {
+result_octets := %bin('39383730')
+if !(result_octets == 0x39383730) {
test_fail
}
-&result_octets := %bin('0x39383731')
-if !(&result_octets == 0x39383731) {
+result_octets := %bin('0x39383731')
+if !(result_octets == 0x39383731) {
test_fail
}
-&result_octets := %bin('012')
-if (&result_octets) {
+result_octets := %bin('012')
+if (result_octets) {
test_fail
}
-&result_octets := %bin('0x')
-if (&result_octets) {
+result_octets := %bin('0x')
+if (result_octets) {
test_fail
}
-&result_octets := %bin('0x234')
-if (&result_octets) {
+result_octets := %bin('0x234')
+if (result_octets) {
test_fail
}
-&result_octets := %bin('fg')
-if (&result_octets) {
+result_octets := %bin('fg')
+if (result_octets) {
test_fail
}
-&result_octets := %bin('0x23450x1234')
-if (&result_octets) {
+result_octets := %bin('0x23450x1234')
+if (result_octets) {
test_fail
}
-&request += {
- &NAS-Identifier = '0001'
- &NAS-Identifier = '0x030405'
+request += {
+ NAS-Identifier = '0001'
+ NAS-Identifier = '0x030405'
}
-&Class := %bin(%{NAS-Identifier[*]})
+Class := %bin(%{NAS-Identifier[*]})
-if (&Class[#] != 2) {
+if (Class[#] != 2) {
test_fail
}
-if !((&Class[0] == 0x0001) && (&Class[1] == 0x030405)) {
+if !((Class[0] == 0x0001) && (Class[1] == 0x030405)) {
test_fail
}
-if (&User-Name == "bob") {
+if (User-Name == "bob") {
break # ERROR
}
# PRE: if
#
call second {
- &reply += {
- &Reply-Message = 'call second post'
+ reply += {
+ Reply-Message = 'call second post'
}
}
-if (!&reply.Reply-Message) {
+if (!reply.Reply-Message) {
test_fail
}
-if (!(&reply.Reply-Message[0] == "call second")) {
+if (!(reply.Reply-Message[0] == "call second")) {
test_fail
}
-if (!(&reply.Reply-Message[1] == "call second post")) {
+if (!(reply.Reply-Message[1] == "call second post")) {
test_fail
}
-&reply -= &Reply-Message[*]
+reply -= Reply-Message[*]
success
call second {
}
-if (!&reply.Reply-Message) {
+if (!reply.Reply-Message) {
test_fail
}
-if (!(&reply.Reply-Message[0] == "call second")) {
+if (!(reply.Reply-Message[0] == "call second")) {
test_fail
}
-&reply -= &Reply-Message
+reply -= Reply-Message
success
#
test_fail
-switch &reply.Filter-Id {
+switch reply.Filter-Id {
# deliberately empty
case "filter" {
}
- case &Not-Dynamically-Allocated { # ERROR
+ case Not-Dynamically-Allocated { # ERROR
test_fail
}
# PRE: switch
#
-switch &reply.Filter-Id {
+switch reply.Filter-Id {
case "filter" {
ok
}
# PRE: switch
#
-switch &reply.Filter-Id {
+switch reply.Filter-Id {
# deliberately empty
case "filter" {
}
# PRE: switch
#
-&Filter-Id := ""
+Filter-Id := ""
-switch &Filter-Id {
+switch Filter-Id {
case "" {
success
}
case "doug" {
- &reply.Filter-Id := "doug"
+ reply.Filter-Id := "doug"
}
case {
- &reply.Filter-Id := "default"
+ reply.Filter-Id := "default"
}
}
#
# PRE: if
#
-&Class := 0xad
+Class := 0xad
-if ((byte)&Class == 173) {
+if ((byte)Class == 173) {
success
}
-if ((byte)&Class < 173) {
+if ((byte)Class < 173) {
test_fail
}
-if ((byte)&Class > 173) {
+if ((byte)Class > 173) {
test_fail
}
#
# PRE: if
#
-&Class := 0x00000101
+Class := 0x00000101
-if ((integer)&Class[0] == 257) {
+if ((integer)Class[0] == 257) {
success
}
-if ((integer)&Class[0] < 256) {
+if ((integer)Class[0] < 256) {
test_fail
}
-if ((integer)&Class[0] > 257) {
+if ((integer)Class[0] > 257) {
test_fail
}
-&zscore := 1
+zscore := 1
-&foo := (uint64) 0x10000000000001
+foo := (uint64) 0x10000000000001
-if (&foo != (&zscore + %cast('uint64', 0x10000000000000))) {
+if (foo != (zscore + %cast('uint64', 0x10000000000000))) {
test_fail
}
-if (&foo != (&zscore + (uint64) 0x10000000000000)) {
+if (foo != (zscore + (uint64) 0x10000000000000)) {
test_fail
}
-&Service-Type := ::Framed-User
+Service-Type := ::Framed-User
-if ((uint32) &Service-Type != 2) {
+if ((uint32) Service-Type != 2) {
test_fail
}
# Cast Service-Type to it's underlying data type,
# which means "don't print the enum name".
#
-if ("%{(uint32) &Service-Type}" != "2") {
+if ("%{(uint32) Service-Type}" != "2") {
test_fail
}
ipv6addr result_ipv6addr
ipv6prefix result_ipv6prefix
-&NAS-IP-Address := 127.0.0.1
-&test_integer := 0x7f000001
+NAS-IP-Address := 127.0.0.1
+test_integer := 0x7f000001
-&test_string := &NAS-IP-Address
+test_string := NAS-IP-Address
-if (!((ipaddr)&test_integer == &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.
#
-&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
+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
#
-&result_ipv6addr := &test_ipaddr
-if (!(&result_ipv6addr == ::ffff:203.0.113.1)) {
+result_ipv6addr := test_ipaddr
+if (!(result_ipv6addr == ::ffff:203.0.113.1)) {
test_fail
}
#
# IPv6 address to IPv4 address
#
-&result_ipaddr := &result_ipv6addr
-if (!(&result_ipaddr == 203.0.113.1)) {
+result_ipaddr := result_ipv6addr
+if (!(result_ipaddr == 203.0.113.1)) {
test_fail
}
#
# IPv4 prefix to IPv6 prefix
#
-&result_ipv6prefix := &test_ipv4prefix1
-if (!(&result_ipv6prefix == ::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
#
-&result_ipv4prefix := &result_ipv6prefix
-if (!(&result_ipv4prefix == 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
#
-&result_ipv6addr := &test_ipv4prefix2
-if (!(&result_ipv6addr == ::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
#
-&result_ipaddr := &test_ipv6prefix2
-if (!(&result_ipaddr == 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)
#
-&result_ipv6prefix := &test_ipaddr
-if (!(&result_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)
#
-&result_ipv4prefix := &test_ipv6addr2
-if (!(&result_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)
#
-&result_ipv4prefix := &test_ipaddr
-if (!(&result_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)
#
-&result_ipv6prefix := &test_ipv6addr1
-if (!(&result_ipv6prefix == 2001:DB8::1/128)) {
+result_ipv6prefix := test_ipv6addr1
+if (!(result_ipv6prefix == 2001:DB8::1/128)) {
test_fail
}
#
# IPv4 prefix (32) to IPv4 address
#
-&result_ipaddr := &test_ipv4prefix2
-if (!(&result_ipaddr == 203.0.113.1)) {
+result_ipaddr := test_ipv4prefix2
+if (!(result_ipaddr == 203.0.113.1)) {
test_fail
}
#
# IPv6 prefix (128) to IPv6 address
#
-&result_ipv6addr := &test_ipv6prefix2
-if (!(&result_ipv6addr == ::ffff:203.0.113.1)) {
+result_ipv6addr := test_ipv6prefix2
+if (!(result_ipv6addr == ::ffff:203.0.113.1)) {
test_fail
}
#
redundant {
group {
- &result_ipv6addr := &test_ipv6prefix1
+ result_ipv6addr := test_ipv6prefix1
fail
}
group {
- 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') {
+ 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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipaddr := &test_ipv6prefix3
+ result_ipaddr := test_ipv6prefix3
fail
}
group {
- 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') {
+ 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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipv4prefix := &test_ipv6prefix3
+ result_ipv4prefix := test_ipv6prefix3
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &result_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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipv6addr := &test_ipv4prefix1
+ result_ipv6addr := test_ipv4prefix1
fail
}
group {
- 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') {
+ 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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipaddr := &test_ipv4prefix1
+ result_ipaddr := test_ipv4prefix1
fail
}
group {
- 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') {
+ 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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipaddr := &test_ipv6prefix1
+ result_ipaddr := test_ipv6prefix1
fail
}
group {
- 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') {
+ 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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipv4prefix := &test_ipv6prefix1
+ result_ipv4prefix := test_ipv6prefix1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &result_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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipaddr := &test_ipv6addr1
+ result_ipaddr := test_ipv6addr1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &result_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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
redundant {
group {
- &result_ipv4prefix := &test_ipv6addr1
+ result_ipv4prefix := test_ipv6addr1
fail
}
group {
- if !(&Module-Failure-Message == 'Assigning value to &result_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[*]
+ request -= Module-Failure-Message[*]
ok
}
}
#
# PRE: if
#
-&Class := 0x0101
+Class := 0x0101
-if ((short)&Class == 257) {
+if ((short)Class == 257) {
success
}
-if ((short)&Class < 256) {
+if ((short)Class < 256) {
test_fail
}
-if ((short)&Class > 257) {
+if ((short)Class > 257) {
test_fail
}
#
# These dates are one minute apart.
#
-&one = "2024-08-12T00:00:00Z"
-&two = "2024-08-12T00:01:00Z"
+one = "2024-08-12T00:00:00Z"
+two = "2024-08-12T00:01:00Z"
-&diff = &two - &one
-if (&diff != 60s) {
+diff = two - one
+if (diff != 60s) {
test_fail
}
#
# Cast the time delta to milliseconds
#
-&num = %cast("ms", %{diff})
+num = %cast("ms", %{diff})
#
# This results in 60, because the conversion to fr_value_box_cast() doesn't pass dst->enumv?
#
-if (&num != 60000) {
+if (num != 60000) {
test_fail
}
#
# Not really, but it's a way to test cross-protocol issues
#
-&Proto.radius.User-Name = 'uid'
-&Password.With-Header = 'userPassword'
+Proto.radius.User-Name = 'uid'
+Password.With-Header = 'userPassword'
success
-&Called-Station-Id := "This is a test"
-&Calling-Station-Id := "This is a test"
+Called-Station-Id := "This is a test"
+Calling-Station-Id := "This is a test"
#
# Check attribute references
#
-if (&Called-Station-Id == &Calling-Station-Id) {
+if (Called-Station-Id == Calling-Station-Id) {
success
}
#
# "foo" does not yet exist. So it doesn't have value "42"
#
-if (&foo != 42) {
- &result += 1
+if (foo != 42) {
+ result += 1
}
#
# This should be the same as above.
#
-if !(&foo == 42) {
- &result += 1
+if !(foo == 42) {
+ result += 1
}
-if !&result {
+if !result {
test_fail
}
-if (&result != 2) {
+if (result != 2) {
test_fail
}
success
#
# PRE: if
#
-&NAS-IP-Address := 127.0.0.1
-&Framed-IP-Address := 127.0.0.1
+NAS-IP-Address := 127.0.0.1
+Framed-IP-Address := 127.0.0.1
#
# Check attribute references
#
-if (!(&NAS-IP-Address == &Framed-IP-Address)) {
+if (!(NAS-IP-Address == Framed-IP-Address)) {
test_fail
}
-&NAS-IP-Address := 0.0.0.0
-&Framed-IP-Address := 255.255.255.255
+NAS-IP-Address := 0.0.0.0
+Framed-IP-Address := 255.255.255.255
-if (!(!(&NAS-IP-Address == &Framed-IP-Address))) {
+if (!(!(NAS-IP-Address == Framed-IP-Address))) {
test_fail
}
-if (!(&NAS-IP-Address < &Framed-IP-Address)) {
+if (!(NAS-IP-Address < Framed-IP-Address)) {
test_fail
}
-if (&NAS-IP-Address > &Framed-IP-Address) {
+if (NAS-IP-Address > Framed-IP-Address) {
test_fail
}
# 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
- &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
+control -= Password
+
+control += {
+ User-Name = request.User-Name
+ User-Password = request.User-Password
+ 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
}
#
-# &ref could return a list.
-# (&ref) means "treat the list as one value"
-# (string) (&ref) casts that one value to a string
+# ref could return a list.
+# (ref) means "treat the list as one value"
+# (string) (ref) casts that one value to a string
# and returns one string
#
-&result_string := %{(string) (&control.NAS-Port[*])}
-if !(&result_string == "456789") {
+result_string := %{(string) (control.NAS-Port[*])}
+if !(result_string == "456789") {
test_fail
}
#
-# &ref could return a list.
+# ref could return a list.
#
# Which we then cast individually to the LHS
#
-&Called-Station-Id := &control.NAS-Port[*]
-if !(&Called-Station-Id[0] == "456") {
+Called-Station-Id := control.NAS-Port[*]
+if !(Called-Station-Id[0] == "456") {
test_fail
}
-if !(&Called-Station-Id[1] == "789") {
+if !(Called-Station-Id[1] == "789") {
test_fail
}
-&control -= &NAS-Port[*]
+control -= NAS-Port[*]
ok # separate updates
-&result_string := %concat(%{control.[*]}, ', ')
+result_string := %concat(%{control.[*]}, ', ')
"%{result_string}"
-if (!(&result_string == "bob, hello, ab c, de fg, 123")) {
+if (!(result_string == "bob, hello, ab c, de fg, 123")) {
test_fail
}
-&result_string := %concat(%{control.Calling-Station-Id[*]}, ', ')
+result_string := %concat(%{control.Calling-Station-Id[*]}, ', ')
-if (!(&result_string == "ab c, de fg")) {
+if (!(result_string == "ab c, de fg")) {
test_fail
}
# Empty separator
-&result_string := %concat(%{control.Calling-Station-Id[*]})
+result_string := %concat(%{control.Calling-Station-Id[*]})
-if (!(&result_string == "ab cde fg")) {
+if (!(result_string == "ab cde fg")) {
test_fail
}
# Single character separator
-&result_string := %concat(%{control.Calling-Station-Id[*]}, ',')
+result_string := %concat(%{control.Calling-Station-Id[*]}, ',')
-if (!(&result_string == "ab c,de fg")) {
+if (!(result_string == "ab c,de fg")) {
test_fail
}
# Multi character separator not delimited
-&result_string := %concat(%{control.Calling-Station-Id[*]}, '|-')
+result_string := %concat(%{control.Calling-Station-Id[*]}, '|-')
-if !(&result_string == "ab c|-de fg") {
+if !(result_string == "ab c|-de fg") {
test_fail
}
string result_string
-&result_string := &reply.Filter-Id[#] # ERROR
+result_string := reply.Filter-Id[#] # ERROR
date test_date
# Use pre-defined date and time
-&test_integer := 1506101100
+test_integer := 1506101100
# Convert to string representation
-&result_string1 := %date(%{test_integer})
+result_string1 := %date(%{test_integer})
# Some systems report GMT some UTC...
-if (!(&result_string1 == "Fri 22 Sep 17:25:00 GMT 2017")) && (!(&result_string1 == "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
-&result_integer := %date(%{result_string1})
+result_integer := %date(%{result_string1})
-if (!(&result_integer == &test_integer)) {
+if (!(result_integer == test_integer)) {
test_fail
}
# Compare two methods of reading request timestamp in local timezone
-&result_string1 := %localdate(request)
-&result_string2 := %S
+result_string1 := %localdate(request)
+result_string2 := %S
-if (!(&result_string1 == &result_string2)) {
+if (!(result_string1 == result_string2)) {
test_fail
}
# Convert different string format
-&result_string1 := "2017-09-22 17:25:00"
+result_string1 := "2017-09-22 17:25:00"
-&result_integer := %sqldate(%{result_string1})
+result_integer := %sqldate(%{result_string1})
-if (!(&result_integer == &test_integer)) {
+if (!(result_integer == test_integer)) {
test_fail
}
# Use a date attribute
-&test_date := 1659985459
-&result_string1 := %sqldate(%{test_date})
+test_date := 1659985459
+result_string1 := %sqldate(%{test_date})
-if !(&result_string1 == '2022-08-08 19:04:19') {
+if !(result_string1 == '2022-08-08 19:04:19') {
test_fail
}
# Invalid format
-&result_string1 := '201-32-22 17:25:00'
-&result_string2 := %sqldate(%{result_string1})
+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 (&result_string2) {
+if (result_string2) {
test_fail
}
-if (!(&Module-Failure-Message == "Failed to parse time string \"201-32-22 17:25:00\" as format '\%Y-\%m-\%d \%H:\%M:\%S'")) {
+if (!(Module-Failure-Message == "Failed to parse time string \"201-32-22 17:25:00\" as format '\%Y-\%m-\%d \%H:\%M:\%S'")) {
test_fail
}
# Invalid type
-&NAS-IP-Address := "192.168.1.1"
-&result_string2 := %date(%{NAS-IP-Address})
+NAS-IP-Address := "192.168.1.1"
+result_string2 := %date(%{NAS-IP-Address})
-if (&result_string2) {
+if (result_string2) {
test_fail
}
-if (!(&Module-Failure-Message == "Can't convert type ipaddr into date")) {
+if (!(Module-Failure-Message == "Can't convert type ipaddr into date")) {
test_fail
}
#
# Do date comparisons
#
-if (&test_date != (date) 'Aug 8 2022 19:04:19 UTC') {
+if (test_date != (date) 'Aug 8 2022 19:04:19 UTC') {
test_fail
}
-if (&test_date < (date) 'Aug 8 2022 18:00:00 UTC') {
+if (test_date < (date) 'Aug 8 2022 18:00:00 UTC') {
test_fail
}
-if (&test_date > (date) 'Aug 9 2022 00:04:19 UTC') {
+if (test_date > (date) 'Aug 9 2022 00:04:19 UTC') {
test_fail
}
uint32 test_integer
string dummy_string
-&test_integer := "%debug(4)"
+test_integer := "%debug(4)"
# Check debug level is now 4
if (!(%debug(3) == 4)) {
#
uint32 test_integer1
uint32 test_integer2
-&test_integer1 := 4
-&test_integer2 := 6
+test_integer1 := 4
+test_integer2 := 6
#
# Many, many, years of work led up to this!
#
-&test_integer1 += 5
+test_integer1 += 5
-if (!(&test_integer1 == 9)) {
+if (!(test_integer1 == 9)) {
test_fail
}
-&test_integer1 += &test_integer2
-if (!(&test_integer1 == 15)) {
+test_integer1 += test_integer2
+if (!(test_integer1 == 15)) {
test_fail
}
uint32 test_integer3
group test_group
-&test_integer1 += 4
-if !(&test_integer1 == 4) {
+test_integer1 += 4
+if !(test_integer1 == 4) {
test_fail
}
-&test_string += "bar"
-if !(&test_string == "bar") {
+test_string += "bar"
+if !(test_string == "bar") {
test_fail
}
-&test_group += {
- &Filter-Id = "foo"
+test_group += {
+ Filter-Id = "foo"
}
-if !&test_group {
+if !test_group {
test_fail
}
-if !(&test_group.Filter-Id == "foo") {
+if !(test_group.Filter-Id == "foo") {
test_fail
}
-&test_integer2 := 3
-&test_integer3 := 4
+test_integer2 := 3
+test_integer3 := 4
-&test_integer1 += &test_integer3 - &test_integer2
-if !(&test_integer1 == 5) {
+test_integer1 += test_integer3 - test_integer2
+if !(test_integer1 == 5) {
test_fail
}
#
# Form attribute references with xlats
#
-&request += {
- &Filter-Id = 'foo'
- &Filter-Id = 'bar'
- &Calling-Station-Id = 'baz'
+request += {
+ Filter-Id = 'foo'
+ Filter-Id = 'bar'
+ Calling-Station-Id = 'baz'
}
-&control = {}
+control = {}
if (!(%{Filter-Id[#]} == 2)) {
test_fail
}
-if (!(&Filter-Id[0] == 'foo')) {
+if (!(Filter-Id[0] == 'foo')) {
test_fail
}
#
# Delete an attribute by assigning a non-existent attribute to it
#
-&Filter-Id[1] := &Reply-Message
+Filter-Id[1] := Reply-Message
# Should only remove 'bar'
-if !(&Filter-Id[0] == 'foo') {
+if !(Filter-Id[0] == 'foo') {
test_fail
}
-if (!(&Filter-Id[#] == 1)) {
+if (!(Filter-Id[#] == 1)) {
test_fail
}
# Nothing should exist for this attribute.
-if (&Filter-Id[1]) {
+if (Filter-Id[1]) {
test_fail
}
-if (&Filter-Id[2]) {
+if (Filter-Id[2]) {
test_fail
}
-&Filter-Id := &Reply-Message
+Filter-Id := Reply-Message
# All instances should be removed
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
uint32 small
uint32 large
- &large = 10000
- &small = 10
+ large = 10000
+ small = 10
#
# Enforce it
#
- &large <= &small
+ large <= small
- if !(&large == &small) {
+ if !(large == small) {
test_fail
}
uint32 foo
-&Tmp-Integer-0 := 1
-&Tmp-Integer-1 := { 3, 6, 9 }
+Tmp-Integer-0 := 1
+Tmp-Integer-1 := { 3, 6, 9 }
-&foo = %eval(%{'%{Tmp-Integer-1[' + "%{Tmp-Integer-0}" + ']}'})
+foo = %eval(%{'%{Tmp-Integer-1[' + "%{Tmp-Integer-0}" + ']}'})
-if (&foo != 6) {
+if (foo != 6) {
test_fail
}
# them are rolled back.
#
transaction {
- &test_string1 := "foo"
- &test_string2 -= "bar" # fails, no existing test_string2
- &test_string3 := "bar"
+ test_string1 := "foo"
+ test_string2 -= "bar" # fails, no existing test_string2
+ test_string3 := "bar"
}
-if (&test_string1) {
+if (test_string1) {
test_fail
}
-if (&test_string2) {
+if (test_string2) {
test_fail
}
-if (&test_string3) {
+if (test_string3) {
test_fail
}
# All of these succeed individually, so all of them should succeed.
#
transaction {
- &test_string1 := "foo"
- &test_string2 := "yup"
- &test_string3 := "bar"
+ test_string1 := "foo"
+ test_string2 := "yup"
+ test_string3 := "bar"
}
-if (!(&test_string1 == "foo")) {
+if (!(test_string1 == "foo")) {
test_fail
}
-if (!(&test_string2 == "yup")) {
+if (!(test_string2 == "yup")) {
test_fail
}
-if (!(&test_string3 == "bar")) {
+if (!(test_string3 == "bar")) {
test_fail
}
# PRE: edit-list
#
-&control.Filter-Id := "foo"
-&reply.Filter-Id := "foo"
+control.Filter-Id := "foo"
+reply.Filter-Id := "foo"
-&reply &= &control
+reply &= control
# must exist
-if (!&reply.Filter-Id) {
+if (!reply.Filter-Id) {
test_fail
}
# and have the correct value
-if (!(&reply.Filter-Id == "foo")) {
+if (!(reply.Filter-Id == "foo")) {
test_fail
}
# reset
-&reply -= &Filter-Id[*]
+reply -= Filter-Id[*]
#
# Same attribute, but different value
#
-&reply.Filter-Id := "bar"
+reply.Filter-Id := "bar"
-&reply &= &control
+reply &= control
# must NOT exist
-if (&reply.Filter-Id) {
+if (reply.Filter-Id) {
test_fail
}
string test_string2
string test_string3
-&test_string1 := "foo"
-&test_string2 := &test_string1
-&test_string3 := "test_string1"
+test_string1 := "foo"
+test_string2 := test_string1
+test_string3 := "test_string1"
# foo, bar, "foo", "foo"
-&Filter-Id := { &test_string1, "bar", "%{test_string1}", %{test_string3} }
+Filter-Id := { test_string1, "bar", "%{test_string1}", %{test_string3} }
if (!(%{Filter-Id[#]} == 4)) {
uint32 foo
-&foo := 42
+foo := 42
-if !(&foo == 42) {
+if !(foo == 42) {
test_fail
}
#
# This is "delete"
#
-&foo := {}
+foo := {}
-if &foo {
+if foo {
test_fail
}
success
uint32 foo
-&foo := 42
+foo := 42
-if !(&foo == 42) {
+if !(foo == 42) {
test_fail
}
-&foo += {} # ERROR not allowed!
+foo += {} # ERROR not allowed!
-&NAS-Port := 1
-&NAS-Port += { 11, 17, 19, 23 }
+NAS-Port := 1
+NAS-Port += { 11, 17, 19, 23 }
-if !(&NAS-Port[#] == 1) {
+if !(NAS-Port[#] == 1) {
test_fail
}
-if !(&NAS-Port == 71) {
+if !(NAS-Port == 71) {
test_fail
}
#
# PRE: edit
#
-&Filter-Id := {
+Filter-Id := {
"foo %{User-Name}",
"bar",
"baz",
- &User-Name
+ User-Name
}
if (!(%{request.Filter-Id[#]} == 4)) {
test_fail
}
-if (!(&Filter-Id[0] == "foo bob")) {
+if (!(Filter-Id[0] == "foo bob")) {
test_fail
}
-if (!(&Filter-Id[1] == "bar")) {
+if (!(Filter-Id[1] == "bar")) {
test_fail
}
-if (!(&Filter-Id[2] == "baz")) {
+if (!(Filter-Id[2] == "baz")) {
test_fail
}
-if (!(&Filter-Id[3] == "bob")) {
+if (!(Filter-Id[3] == "bob")) {
test_fail
}
#
# And test non-string things
#
-&Filter-Id := "127"
+Filter-Id := "127"
-&Framed-IP-Address := {
+Framed-IP-Address := {
"%{Filter-Id}.0.0.1",
192.0.2.1
}
test_fail
}
-if (!(&Framed-IP-Address[0] == 127.0.0.1)) {
+if (!(Framed-IP-Address[0] == 127.0.0.1)) {
test_fail
}
-if (!(&Framed-IP-Address[1] == 192.0.2.1)) {
+if (!(Framed-IP-Address[1] == 192.0.2.1)) {
test_fail
}
# PRE: edit
#
-&Framed-IP-Address := 0x7f000001
+Framed-IP-Address := 0x7f000001
-if (!&Framed-IP-Address) {
+if (!Framed-IP-Address) {
test_fail
}
-if (!(&Framed-IP-Address == 127.0.0.1)) {
+if (!(Framed-IP-Address == 127.0.0.1)) {
test_fail
}
#
uint32 result_integer
-&NAS-Port := { 1, 3, 5, 7, 11 }
+NAS-Port := { 1, 3, 5, 7, 11 }
#
# Do operations on sets of inputs.
#
-&result_integer += &NAS-Port[*]
-if (!(&result_integer == 27)) {
+result_integer += NAS-Port[*]
+if (!(result_integer == 27)) {
test_fail
}
#
# We should be able to copy multiple attributes
#
-&Port-Limit := &NAS-Port[*]
-&result_integer := 0
+Port-Limit := NAS-Port[*]
+result_integer := 0
#
# Do operations on sets of inputs.
#
-&result_integer += &Port-Limit[*]
-if (!(&result_integer == 27)) {
+result_integer += Port-Limit[*]
+if (!(result_integer == 27)) {
test_fail
}
# PRE: edit
#
-&control.Filter-Id := "foo"
+control.Filter-Id := "foo"
# Doesn't exist
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
# append
-&request += &control
+request += control
# Does exist, and is the last attribute
-if (!&Filter-Id[n]) {
+if (!Filter-Id[n]) {
test_fail
}
-&request -= &Filter-Id[*]
+request -= Filter-Id[*]
# Doesn't exist
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
# prepend
-&request ^= &control
+request ^= control
# Does exist, and is at offset 0
-if (!&Filter-Id[0]) {
+if (!Filter-Id[0]) {
test_fail
}
-&request -= &Filter-Id[*]
-&control.Filter-Id := { "a", "b", "c", "d" }
+request -= Filter-Id[*]
+control.Filter-Id := { "a", "b", "c", "d" }
-&request += &control.Filter-Id[*]
+request += control.Filter-Id[*]
if (!(%{request.Filter-Id[#]} == 4)) {
test_fail
}
#
# PRE: if edit-list
#
-&control.Filter-Id = { 'A', 'B' }
+control.Filter-Id = { 'A', 'B' }
if !(%{control.Filter-Id[#]} == 2) {
test_fail
}
-if !(&control.Filter-Id[1] == 'B') {
+if !(control.Filter-Id[1] == 'B') {
test_fail
}
#
# Add of SECOND bit fails
#
-&control.Filter-Id = { 'C', 'D' }
+control.Filter-Id = { 'C', 'D' }
if !(%{control.Filter-Id[#]} == 2) {
test_fail
}
-if !(&control.Filter-Id[0] == 'A') {
+if !(control.Filter-Id[0] == 'A') {
test_fail
}
-if !(&control.Filter-Id[1] == 'B') {
+if !(control.Filter-Id[1] == 'B') {
test_fail
}
#
# PRE: edit-list
#
-&control.TLS-Certificate := {
- &Issuer = "test"
+control.TLS-Certificate := {
+ Issuer = "test"
}
-if !(&control.TLS-Certificate.Issuer == "test") {
+if !(control.TLS-Certificate.Issuer == "test") {
test_fail
}
#
# The name on the LHS MUST be given in the context of the parent.
#
-&reply += {
- &request.User-Name = "foo" # ERROR
+reply += {
+ request.User-Name = "foo" # ERROR
}
# PRE: edit-list
#
-&request += {
- &Class = 0x00
- &Filter-Id = "foo"
- &NAS-Port = 1
+request += {
+ Class = 0x00
+ Filter-Id = "foo"
+ NAS-Port = 1
}
# Does exist
-if (!&Filter-Id) {
+if (!Filter-Id) {
test_fail
}
# Remove the first one
-&request -= &Filter-Id
+request -= Filter-Id
# Does not exist
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
# Other things still exist
-if (!&Class) {
+if (!Class) {
test_fail
}
-if (!&NAS-Port) {
+if (!NAS-Port) {
test_fail
}
#
# Add multiple of the same type
#
-&request += {
- &Filter-Id = "foo"
- &Filter-Id = "bar"
- &Filter-Id = "baz"
+request += {
+ Filter-Id = "foo"
+ Filter-Id = "bar"
+ Filter-Id = "baz"
}
-if (!&Filter-Id) {
+if (!Filter-Id) {
test_fail
}
-&request -= &Filter-Id[0]
+request -= Filter-Id[0]
# the first one has been removed
-if (!(&Filter-Id[0] == "bar")) {
+if (!(Filter-Id[0] == "bar")) {
test_fail
}
# Other things still exist
-if (!&Class) {
+if (!Class) {
test_fail
}
-if (!&NAS-Port) {
+if (!NAS-Port) {
test_fail
}
-&request -= &Filter-Id[*]
+request -= Filter-Id[*]
# Does not exist
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
-&Filter-Id := { "foo", "bar", "baz" }
+Filter-Id := { "foo", "bar", "baz" }
#
# Remove one by value.
# @todo - allow for == or =~ in the RHS list,
# as a condition? For now, it's an exact match. :(
#
-&request -= {
- &Filter-Id == "bar"
+request -= {
+ Filter-Id == "bar"
}
-if (!(&Filter-Id[0] == "foo")) {
+if (!(Filter-Id[0] == "foo")) {
test_fail
}
-if (!(&Filter-Id[1] == "baz")) {
+if (!(Filter-Id[1] == "baz")) {
test_fail
}
-if (&Filter-Id[2]) {
+if (Filter-Id[2]) {
test_fail
}
#
# Remove via in-place list, too.
#
-&request -= "Filter-Id == 'foo'"
-if (!(&Filter-Id[0] == "baz")) {
+request -= "Filter-Id == 'foo'"
+if (!(Filter-Id[0] == "baz")) {
test_fail
}
-if (&Filter-Id[1]) {
+if (Filter-Id[1]) {
test_fail
}
#
# Instead of doing something wrong, we forbid it with a descriptive error.
#
-&control -= {
- &Password.Cleartext == 'oracle01' # ERROR
+control -= {
+ Password.Cleartext == 'oracle01' # ERROR
}
\ No newline at end of file
-&reply.Reply-Message := "foo"
-if (!&reply.Reply-Message) {
+reply.Reply-Message := "foo"
+if (!reply.Reply-Message) {
test_fail
}
#
# The default list here is the LHS list, not "request".
#
-&reply -= &Reply-Message[*]
+reply -= Reply-Message[*]
# Does not exist
-if (&reply.Reply-Message) {
+if (reply.Reply-Message) {
test_fail
}
# PRE: edit-list
#
-&control.Filter-Id := "foo"
+control.Filter-Id := "foo"
# must exist
-if (!&control.Filter-Id) {
+if (!control.Filter-Id) {
test_fail
}
#
# Reset the list to empty contents
#
-&control := {}
+control := {}
# must not exist
-if (&control.Filter-Id) {
+if (control.Filter-Id) {
test_fail
}
group test_group1
group test_group2
-&test_group1.NAS-Port := { 1, 3, 5, 7, 11 }
-&Port-Limit := 0
+test_group1.NAS-Port := { 1, 3, 5, 7, 11 }
+Port-Limit := 0
#
# Do operations on sets of inputs.
#
-&Port-Limit += &test_group1.NAS-Port[*]
-if (!(&Port-Limit == 27)) {
+Port-Limit += test_group1.NAS-Port[*]
+if (!(Port-Limit == 27)) {
test_fail
}
-&test_group2 := &test_group1
-&Port-Limit := 0
+test_group2 := test_group1
+Port-Limit := 0
-&Port-Limit += &test_group2.NAS-Port[*]
-if (!(&Port-Limit == 27)) {
+Port-Limit += test_group2.NAS-Port[*]
+if (!(Port-Limit == 27)) {
test_fail
}
#
# The purpose of this functionality is mainly for xlat, exec, etc.
#
-&control += "NAS-Port = 9"
+control += "NAS-Port = 9"
-if (!(&control.NAS-Port == 9)) {
+if (!(control.NAS-Port == 9)) {
test_fail
}
# = A' MERGE B' if A and B are lists
#
-&Filter-Id := "foo"
-&control.Filter-Id := "bar"
+Filter-Id := "foo"
+control.Filter-Id := "bar"
# merge
-&request >= &control
+request >= control
-if (!&Filter-Id) {
+if (!Filter-Id) {
test_fail
}
# The original value should be unchanged
-if (!(&Filter-Id == "foo")) {
+if (!(Filter-Id == "foo")) {
test_fail
}
# and the new value should not be there
-if (&Filter-Id == "bar") {
+if (Filter-Id == "bar") {
test_fail
}
# = A' MERGE B' if A and B are lists
#
-&Filter-Id := "foo"
-&control.Filter-Id := "bar"
+Filter-Id := "foo"
+control.Filter-Id := "bar"
# merge
-&request <= &control
+request <= control
-if (!&Filter-Id) {
+if (!Filter-Id) {
test_fail
}
# we want the *control* version
-if (!(&Filter-Id == "bar")) {
+if (!(Filter-Id == "bar")) {
test_fail
}
# and the original value should not be there
-if (&Filter-Id == "foo") {
+if (Filter-Id == "foo") {
test_fail
}
string bar
string baz
-&baz = "a,b,c,d,e"
+baz = "a,b,c,d,e"
#
# Append, don't create multiple versions
#
-&bar += %explode(%{baz}, ',')
+bar += %explode(%{baz}, ',')
-if !(&bar == "abcde") {
+if !(bar == "abcde") {
test_fail
}
# We cannot have multiple copies of local variables. There's no real
# reason why, but for now it's safer to be limited.
#
-&foo := %explode(%{baz}, ',')
-if !(&foo[#] == 1) {
+foo := %explode(%{baz}, ',')
+if !(foo[#] == 1) {
test_fail
}
#
# Append
#
-&Reply-Message = "foo"
+Reply-Message = "foo"
-&Reply-Message += { "a", "b", "c" }
+Reply-Message += { "a", "b", "c" }
#
# This seems wrong and inconsistent with Filter-Id below???
#
-if !(&Reply-Message == "fooabc") {
+if !(Reply-Message == "fooabc") {
test_fail
}
-&Filter-Id := { "a", "b", "c" }
-if !(&Filter-Id[#] == 3) {
+Filter-Id := { "a", "b", "c" }
+if !(Filter-Id[#] == 3) {
test_fail
}
#
# List by reference
#
-&foo := ""
-&foo += &Filter-Id[*]
-if !(&foo == "abc") {
+foo := ""
+foo += Filter-Id[*]
+if !(foo == "abc") {
test_fail
}
-&request -= &Reply-Message
+request -= Reply-Message
#
# Attribute references in in-place lists work.
#
-&Reply-Message := { &Filter-ID[2], &Filter-ID[1], &Filter-ID[0] }
-if !(&Reply-Message[#] == 3) {
+Reply-Message := { Filter-ID[2], Filter-ID[1], Filter-ID[0] }
+if !(Reply-Message[#] == 3) {
test_fail
}
-if (&Reply-Message[0] != 'c') {
+if (Reply-Message[0] != 'c') {
test_fail
}
# This would make sense, but it doesn't work. Instead it says:
#
# Missing attribute value
-# Failed creating map from '&Reply-Message = (null)'
+# Failed creating map from 'Reply-Message = (null)'
#
-#&Tmp-Group-0 := { &Reply-Message, &Filter-Id }
+#Tmp-Group-0 := { Reply-Message, Filter-Id }
success
#
# PRE: if edit-list
#
-&control.User-Name := "foo"
+control.User-Name := "foo"
#
# Create a nested group.
#
-# @todo - we only support ONE layer of nesting under &control,
-# &request, etc. for now. We should support more.
+# @todo - we only support ONE layer of nesting under control,
+# request, etc. for now. We should support more.
#
-&control.Tmp-Group-0 := {
- &NAS-Port = 1
+control.Tmp-Group-0 := {
+ NAS-Port = 1
}
-if (!&control.Tmp-Group-0.NAS-Port) {
+if (!control.Tmp-Group-0.NAS-Port) {
test_fail
}
-if (!(&control.Tmp-Group-0.NAS-Port == 1)) {
+if (!(control.Tmp-Group-0.NAS-Port == 1)) {
test_fail
}
#
# Edit it in place.
#
-&control.Tmp-Group-0.NAS-Port += 5
+control.Tmp-Group-0.NAS-Port += 5
-if (!(&control.Tmp-Group-0.NAS-Port == 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.NAS-Port
+control.Tmp-Group-0 -= control.Tmp-Group-0.NAS-Port
-if (&control.Tmp-Group-0.NAS-Port) {
+if (control.Tmp-Group-0.NAS-Port) {
test_fail
}
#
# Append something to it
#
-&control.Tmp-Group-0 += {
- &Framed-IP-Address = 127.0.0.1
+control.Tmp-Group-0 += {
+ Framed-IP-Address = 127.0.0.1
}
-if (!(&control.Tmp-Group-0.Framed-IP-Address == 127.0.0.1)) {
+if (!(control.Tmp-Group-0.Framed-IP-Address == 127.0.0.1)) {
test_fail
}
#
# Multiple members
#
-&control.Tmp-Group-0 += {
- &Class = 0xabcdef
+control.Tmp-Group-0 += {
+ Class = 0xabcdef
}
-if (!(&control.Tmp-Group-0.Framed-IP-Address == 127.0.0.1)) {
+if (!(control.Tmp-Group-0.Framed-IP-Address == 127.0.0.1)) {
test_fail
}
-if (!(&control.Tmp-Group-0.Class == 0xabcdef)) {
+if (!(control.Tmp-Group-0.Class == 0xabcdef)) {
test_fail
}
#
# PRE: if edit
#
-&request += {
- &Framed-IP-Address = 192.0.2.1
- &Framed-IP-Address = 192.0.2.2
+request += {
+ Framed-IP-Address = 192.0.2.1
+ Framed-IP-Address = 192.0.2.2
}
#
# Delete only the second one
#
-&request.Framed-IP-Address[1] := {}
+request.Framed-IP-Address[1] := {}
-if (&Framed-IP-Address[#] != 1) {
+if (Framed-IP-Address[#] != 1) {
test_fail
}
-if !(&Framed-IP-Address[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
#
uint32 a
-&a := '$[3][2]' # ERROR
+a := '$[3][2]' # ERROR
#
# PRE: edit-list
#
-&request += {
- &Tmp-Group-0 = {}
+request += {
+ Tmp-Group-0 = {}
}
-if (!&request.Tmp-Group-0) {
+if (!request.Tmp-Group-0) {
test_fail
}
-&request.Tmp-Group-0 += {
- &User-Name = "hello"
+request.Tmp-Group-0 += {
+ User-Name = "hello"
}
-if !(&request.Tmp-Group-0.User-Name == "hello") {
+if !(request.Tmp-Group-0.User-Name == "hello") {
test_fail
}
-&request.Tmp-Group-0 += {
- &Tmp-Group-1 = {
- &User-Name = "foo"
+request.Tmp-Group-0 += {
+ Tmp-Group-1 = {
+ User-Name = "foo"
}
}
-if !(&request.Tmp-Group-0.Tmp-Group-1.User-Name == "foo") {
+if !(request.Tmp-Group-0.Tmp-Group-1.User-Name == "foo") {
test_fail
}
#
# PRE: edit
#
-&session-state += {
- &User-Name = "foo"
+session-state += {
+ User-Name = "foo"
}
-if !(&session-state.User-Name == "foo") {
+if !(session-state.User-Name == "foo") {
test_fail
}
# It should still nuke the LHS attributes
#
-&NAS-Port := 1812
-if !(&NAS-Port == 1812) {
+NAS-Port := 1812
+if !(NAS-Port == 1812) {
test_fail
}
#
# Service-Type doesn't exist, so the ":=" means "delete everything"
#
-&NAS-Port := (integer) &Service-Type
+NAS-Port := (integer) Service-Type
#
# This should no longer exist.
#
-if &NAS-Port {
+if NAS-Port {
test_fail
}
#
# left shift octets
#
-&foo := 0xabcdef
-&foo <<= 2
+foo := 0xabcdef
+foo <<= 2
-if (&foo != 0xef) {
+if (foo != 0xef) {
test_fail
}
#
# And right shift
#
-&foo := 0xabcdef
+foo := 0xabcdef
-&foo >>= 2
-if (&foo != 0xab) {
+foo >>= 2
+if (foo != 0xab) {
test_fail
}
success
#
# Some old operators are not allowed.
#
-&reply.Filter-Id !* ANY # ERROR
+reply.Filter-Id !* ANY # ERROR
# PRE: edit
#
string test_string
-&test_string := "foo"
-&test_string ^= "bar"
+test_string := "foo"
+test_string ^= "bar"
-if (!(&test_string == "barfoo")) {
+if (!(test_string == "barfoo")) {
test_fail
}
-&test_string := "foo"
-&test_string += "bar"
+test_string := "foo"
+test_string += "bar"
-if (!(&test_string == "foobar")) {
+if (!(test_string == "foobar")) {
test_fail
}
#
# Subtract is the inverse of add.
#
-&test_string -= "bar"
+test_string -= "bar"
-if (!(&test_string == "foo")) {
+if (!(test_string == "foo")) {
test_fail
}
#
# PRE: edit
#
-&one := 4
-&two := 5
+one := 4
+two := 5
#
# First modification succeeds. The second modification fails, which
# also reverts the changes to the first one.
#
transaction {
- &one += 5
- &two -= 16 # Run-time underflow!
+ one += 5
+ two -= 16 # Run-time underflow!
}
#
# The various edits above should have been reverted.
#
-if !(&one == 4) {
+if !(one == 4) {
test_fail
}
-if !(&two == 5) {
+if !(two == 5) {
test_fail
}
success
# = A' UNION B' if A and B are lists
#
-&Reply-Message := "foo"
-&control.Reply-Message := "bar"
+Reply-Message := "foo"
+control.Reply-Message := "bar"
# union
-&request |= &control
+request |= control
-if (!&Reply-Message) {
+if (!Reply-Message) {
test_fail
}
# The original value should be unchanged
-if (!(&Reply-Message[0] == "foo")) {
+if (!(Reply-Message[0] == "foo")) {
test_fail
}
# and the new value should be there, too
-if (!(&Reply-Message[1] == "bar")) {
+if (!(Reply-Message[1] == "bar")) {
test_fail
}
# PRE: if-empty-allow
#
-if (&User-Name == 'bob') {
+if (User-Name == 'bob') {
ok
}
else {
# "else" has to be preceded by an "if" or "elsif"
#
if (1) {
- &control.Password.Cleartext := "fail"
+ control.Password.Cleartext := "fail"
else { # ERROR
ok
-&Service-Type := ::Framed-User
+Service-Type := ::Framed-User
-if !(&Service-Type == ::Framed-User) {
+if !(Service-Type == ::Framed-User) {
test_fail
}
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'
+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
-&test_string7 := 'ŒČÿ'
-&test_string8 := 'Œ=C4=8Cÿ'
+test_string7 := 'ŒČÿ'
+test_string8 := 'Œ=C4=8Cÿ'
# = not followed by hex and without 2 following chars
-&test_string9 := 'a=Az=y'
+test_string9 := 'a=Az=y'
-if (!((string)%escape.escape("%{test_string1}") == &test_string1)) {
+if (!((string)%escape.escape("%{test_string1}") == test_string1)) {
test_fail
}
-if (!((string)%escape.escape("%{test_string2}") == &test_string4)) {
+if (!((string)%escape.escape("%{test_string2}") == test_string4)) {
test_fail
}
-if (!((string)%escape.escape("%{test_string3}") == &test_string5)) {
+if (!((string)%escape.escape("%{test_string3}") == test_string5)) {
test_fail
}
-if (!((string)%escape.unescape("%{test_string1}") == &test_string1)) {
+if (!((string)%escape.unescape("%{test_string1}") == test_string1)) {
test_fail
}
test_fail
}
-if (!((string)%escape.unescape("%{test_string5}") == &test_string3)) {
+if (!((string)%escape.unescape("%{test_string5}") == test_string3)) {
test_fail
}
-if (!((string)%escape.escape("%{test_string7}") == &test_string8)) {
+if (!((string)%escape.escape("%{test_string7}") == test_string8)) {
test_fail
}
-if (!((string)%escape.unescape("%{test_string8}") == &test_string7)) {
+if (!((string)%escape.unescape("%{test_string8}") == test_string7)) {
test_fail
}
-if (!((string)%escape.unescape("%{test_string9}") == &test_string9)) {
+if (!((string)%escape.unescape("%{test_string9}") == test_string9)) {
test_fail
}
ipaddr test_ipaddr
string result_string
-&test_octets := 0x69206861766520736361727920656d626564646564207468696e67730020696e73696465206d65
-&test_ipaddr := 127.0.0.1
-&request += {
- &Reply-Message = "i have scary embedded things\000 inside me"
- &Reply-Message = "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°"
+test_octets := 0x69206861766520736361727920656d626564646564207468696e67730020696e73696465206d65
+test_ipaddr := 127.0.0.1
+request += {
+ 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'
- &Callback-Number = 'i have scary embedded things\000 inside me'
- &Callback-Number = '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°'
- &Callback-Id = 'i have scary embedded things\000 inside me'
- &Callback-Id = "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°"
+ Callback-Id = 'i have scary embedded things\000 inside me'
+ Callback-Id = "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°"
}
test_fail
}
-&result_string := "%{(string) %{test_octets}}"
-if (!(&result_string == "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 (!(&Reply-Message == "i have scary embedded things\000 inside me")) {
+if (!(Reply-Message == "i have scary embedded things\000 inside me")) {
test_fail
}
-&test_octets := 0x30783031013078303707307830410A307830440D222230786230b0C2b0
-&result_string := "%{(string) %{test_octets}}"
-if (!(&result_string == "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
}
test_fail
}
-if (!(&Reply-Message[1] == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
+if (!(Reply-Message[1] == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
test_fail
}
test_fail
}
-if (!(&Reply-Message[0] == &Reply-Message[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 (!(&Callback-Id[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 (!(&Callback-Id[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) {
+if (!(Callback-Id[1] == "0x01\0010x07\0070x0A\n0x0D\r''0xb0\260°")) {
test_fail
}
#
# Other data types
#
-&result_string := "%{(string) &test_ipaddr}"
+result_string := "%{(string) test_ipaddr}"
if (!(%length(%{result_string}) == 9)) {
test_fail
}
octets test_octets
ether test_ether
-&test_octets := 0x001122334456
+test_octets := 0x001122334456
-&test_ether = &test_octets
+test_ether = test_octets
-if (!(&test_ether == 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 {
- &test_ether := %{Class[42]}
+ test_ether := %{Class[42]}
}
-if (&test_ether) {
+if (test_ether) {
test_fail
}
-&request += %exec('/bin/sh', '-c', '/bin/echo \&Reply-Message = foo')
+request += %exec('/bin/sh', '-c', '/bin/echo \Reply-Message = foo')
-if !(&Reply-Message == 'foo') {
+if !(Reply-Message == 'foo') {
test_fail
}
uint32 baz
uint32 none
-&foo = 1
-&bar = 2
+foo = 1
+bar = 2
-&baz := %{&foo + &bar}
+baz := %{foo + bar}
-if !(&baz == 3) {
+if !(baz == 3) {
test_fail
}
-&baz := %{&none || &foo}
-if !(&baz == &foo) {
+baz := %{none || foo}
+if !(baz == foo) {
test_fail
}
#
# attribute references
#
-&test_integer1 := 3
-&test_integer2 := 4
-&test_date := "%l"
+test_integer1 := 3
+test_integer2 := 4
+test_date := "%l"
-if (!(%{ 1 + 2 * &test_integer1 + 4} == 11)) {
+if (!(%{ 1 + 2 * test_integer1 + 4} == 11)) {
test_fail
}
-if !(1 + 2 * &test_integer1 + 4 == 11) {
+if !(1 + 2 * test_integer1 + 4 == 11) {
test_fail
}
-if (!(%{ 1 + 2 * (&test_integer1 + 4)} == 15)) {
+if (!(%{ 1 + 2 * (test_integer1 + 4)} == 15)) {
test_fail
}
-if !(1 + 2 * (&test_integer1 + 4) == 15) {
+if !(1 + 2 * (test_integer1 + 4) == 15) {
test_fail
}
-if (!(%{ 1 + 2 * (&test_integer1 + &test_integer2)} == 15)) {
+if (!(%{ 1 + 2 * (test_integer1 + test_integer2)} == 15)) {
test_fail
}
-if !(1 + 2 * (&test_integer1 + &test_integer2) == 15) {
+if !(1 + 2 * (test_integer1 + test_integer2) == 15) {
test_fail
}
test_fail
}
-if ("%{ &test_date}" <= 0) {
+if ("%{ test_date}" <= 0) {
test_fail
}
-if (&test_date <= 0) {
+if (test_date <= 0) {
test_fail
}
test_fail
}
-if (!(%{ 6 * -&test_integer2} == -24)) {
+if (!(%{ 6 * -test_integer2} == -24)) {
test_fail
}
-if !(6 * -&test_integer2 == -24) {
+if !(6 * -test_integer2 == -24) {
test_fail
}
# PRE: if edit
#
-&input := %{((uint64)&Acct-Input-Gigawords << 32) | (uint64)&Acct-Input-Octets}
+input := %{((uint64)Acct-Input-Gigawords << 32) | (uint64)Acct-Input-Octets}
-if !(&input == 0) {
+if !(input == 0) {
test_fail
}
-&Acct-Input-Octets := 0
+Acct-Input-Octets := 0
# 0 is false according to the truthy rules, should return 5
-if (!(%{&Acct-Input-Octets || 5} == 5)) {
+if (!(%{Acct-Input-Octets || 5} == 5)) {
test_fail
}
# Both values are not truthy, but it's still more useful to
# return one on them instead of NULL, and this is an extremely
# common use case when setting defaults.
-if ("%{&Acct-Input-Octets || 0}" == '') {
+if ("%{Acct-Input-Octets || 0}" == '') {
test_fail
}
# Same as above, except 5 is truthy, so we DEFINITELY shouldn't
# be returning NULL.
-if ("%{&Acct-Input-Octets || 5}" == '') {
+if ("%{Acct-Input-Octets || 5}" == '') {
test_fail
}
# Completely absent null value is definitely not truthy
-if (!(%{&Acct-Output-Octets || 5} == 5)) {
+if (!(%{Acct-Output-Octets || 5} == 5)) {
test_fail
}
# One null should not trigger the expression returning null overall
-if ("%{&Acct-Output-Octets || 5}" == '') {
+if ("%{Acct-Output-Octets || 5}" == '') {
test_fail
}
#
# @todo - allow just a bare
#
-# &NAS-Port := 5 + (&User-Name == "bob")
+# NAS-Port := 5 + (User-Name == "bob")
#
# which means updating the config file parser, too.
#
-&NAS-Port := %{5 + (&User-Name == "bob")}
+NAS-Port := %{5 + (User-Name == "bob")}
-if !(&NAS-Port == 6) {
+if !(NAS-Port == 6) {
test_fail
}
#
# We only care if this crashes or not.
#
-&Filter-Id := "%{1 + 1} %tolower(1)"
+Filter-Id := "%{1 + 1} %tolower(1)"
success
#
# b is missing, so its default value is 0
#
-&a = 1
-&c = &a - &b
+a = 1
+c = a - b
-if !(&c == &a) {
+if !(c == a) {
test_fail
}
-&sa = "foo"
-&sc = &sa + &sb
+sa = "foo"
+sc = sa + sb
#
# sb is missing, so its default value is the empty string
#
-if !(&sc == &sa) {
+if !(sc == sa) {
test_fail
}
success
# Tests for NUL in the middle of a string
#
-&Reply-Message := "bob\000hello"
+Reply-Message := "bob\000hello"
#
# Commented out because it fails
# test_fail
#}
-if &Reply-Message {
+if Reply-Message {
group tmp
octets delim
#
# Because "\000" yields "zero length delimiter is not allowed"
#
- &delim = 0x00
- &tmp.Reply-Message := %explode(%{Reply-Message}, "%{delim}")
+ delim = 0x00
+ tmp.Reply-Message := %explode(%{Reply-Message}, "%{delim}")
- &Reply-Message := &tmp.Reply-Message[0]
+ Reply-Message := tmp.Reply-Message[0]
}
-if &Reply-Message != "bob" {
+if Reply-Message != "bob" {
test_fail
}
-&request -= &Packet-Type
+request -= Packet-Type
-foreach &Filter-Id {
- &reply += {
- &Called-Station-Id = "%{Foreach-Variable-0}"
+foreach Filter-Id {
+ reply += {
+ Called-Station-Id = "%{Foreach-Variable-0}"
}
}
#
# We DON'T want to see this one.
#
-&request += {
- &Filter-Id = "broken"
+request += {
+ Filter-Id = "broken"
}
-foreach &Filter-Id {
+foreach Filter-Id {
#
# If we see this one, "break" out of the
# foreach loop.
break
}
- &reply += {
- &Called-Station-Id = "%{Foreach-Variable-0}"
+ reply += {
+ Called-Station-Id = "%{Foreach-Variable-0}"
}
}
#
# Adding attribute during request and immediately breaking
#
-&request += {
- &Filter-Id = "1"
- &Filter-Id = "2"
+request += {
+ Filter-Id = "1"
+ Filter-Id = "2"
}
-foreach &Reply-Message {
+foreach Reply-Message {
if ("%{Foreach-Variable-0}" == "1") {
- &request += {
- &Filter-Id = "3"
+ request += {
+ Filter-Id = "3"
}
break
}
}
-&request -= &Filter-Id[*]
+request -= Filter-Id[*]
#
# Adding attribute during request and continuing
#
-&request += {
- &Filter-Id = "1"
- &Filter-Id = "2"
+request += {
+ Filter-Id = "1"
+ Filter-Id = "2"
}
-foreach &Reply-Message {
+foreach Reply-Message {
if ("%{Foreach-Variable-0}" == "1") {
- &request += {
- &Filter-Id = "3"
+ request += {
+ Filter-Id = "3"
}
}
#
string test_string
-&test_string := "ABCDEF_1"
+test_string := "ABCDEF_1"
#
# This creates a bunch of User-Name attributes.
#
-&control.User-Name := { "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.User-Name {
+foreach control.User-Name {
if ("%{test_string}" =~ /([A-Z0-9\-]*)_%{Foreach-Variable-0}/) {
- &test_string := "%{1}"
+ test_string := "%{1}"
success
break
}
#
# PRE: foreach foreach-break
#
-&Calling-Station-Id := "8"
+Calling-Station-Id := "8"
-&control.Calling-Station-Id := { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g" }
+control.Calling-Station-Id := { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g" }
-foreach &control.Calling-Station-Id {
- if (&Calling-Station-Id == "%{Foreach-Variable-0}") {
+foreach control.Calling-Station-Id {
+ if (Calling-Station-Id == "%{Foreach-Variable-0}") {
success
break
}
# PRE: foreach-modify
#
-&Tmp-Integer-0 := { 1, 3, 5, 11 }
+Tmp-Integer-0 := { 1, 3, 5, 11 }
#
# Try to delete one of the variables we're looping over. If the user could delete one,
# then the underlying tmpl_dcursor would crash, as it didn't know about the deletion.
#
-foreach uint32 self (&Tmp-Integer-0) {
- &request -= &Tmp-Integer-0[1]
- &self += 19
+foreach uint32 self (Tmp-Integer-0) {
+ request -= Tmp-Integer-0[1]
+ self += 19
}
-if (&Tmp-Integer-0[0] != 20) {
+if (Tmp-Integer-0[0] != 20) {
test_fail
}
-if (&Tmp-Integer-0[1] != 22) {
+if (Tmp-Integer-0[1] != 22) {
test_fail
}
-if (&Tmp-Integer-0[2] != 24) {
+if (Tmp-Integer-0[2] != 24) {
test_fail
}
-if (&Tmp-Integer-0[3] != 30) {
+if (Tmp-Integer-0[3] != 30) {
test_fail
}
foreach "%tolower('foo')" { # ERROR
- &reply.Called-Station-Id += "%{Foreach-Variable-0}"
+ reply.Called-Station-Id += "%{Foreach-Variable-0}"
}
# PRE: foreach
#
-&control.User-Name := { "0", "1", "2", "3" }
+control.User-Name := { "0", "1", "2", "3" }
-foreach &control.User-Name {
- &control -= {
- &User-Name == "%{1 + %{Foreach-Variable-0}}"
+foreach control.User-Name {
+ control -= {
+ User-Name == "%{1 + %{Foreach-Variable-0}}"
}
- &request += {
- &Filter-Id = "%{Foreach-Variable-0}"
+ request += {
+ Filter-Id = "%{Foreach-Variable-0}"
}
}
-if (!&Filter-Id[0] || !&Filter-Id[1] || !&Filter-Id[2] || !&Filter-Id[3]) {
+if (!Filter-Id[0] || !Filter-Id[1] || !Filter-Id[2] || !Filter-Id[3]) {
test_fail
}
-if (!((&Filter-Id[0] == '0')) || (!(&Filter-Id[1] == '1')) || (!(&Filter-Id[2] == '2')) || (!(&Filter-Id[3] == '3'))) {
+if (!((Filter-Id[0] == '0')) || (!(Filter-Id[1] == '1')) || (!(Filter-Id[2] == '2')) || (!(Filter-Id[3] == '3'))) {
test_fail
}
-if (!&control.User-Name[0] || &control.User-Name[1] || &control.User-Name[2] || &control.User-Name[3]) {
+if (!control.User-Name[0] || control.User-Name[1] || control.User-Name[2] || control.User-Name[3]) {
test_fail
}
-&request -= &Packet-Type[*]
+request -= Packet-Type[*]
-foreach &request.[*] {
- &reply += {
- &Called-Station-Id = "%{Foreach-Variable-0}"
+foreach request.[*] {
+ reply += {
+ Called-Station-Id = "%{Foreach-Variable-0}"
}
}
# PRE: foreach
#
-&Tmp-Integer-0 := { 1, 3, 5, 11 }
+Tmp-Integer-0 := { 1, 3, 5, 11 }
-foreach uint32 self (&Tmp-Integer-0) {
- &self += 19
+foreach uint32 self (Tmp-Integer-0) {
+ self += 19
}
-if (&Tmp-Integer-0[0] != 20) {
+if (Tmp-Integer-0[0] != 20) {
test_fail
}
-if (&Tmp-Integer-0[1] != 22) {
+if (Tmp-Integer-0[1] != 22) {
test_fail
}
-if (&Tmp-Integer-0[2] != 24) {
+if (Tmp-Integer-0[2] != 24) {
test_fail
}
-if (&Tmp-Integer-0[3] != 30) {
+if (Tmp-Integer-0[3] != 30) {
test_fail
}
# PRE: foreach
#
-foreach &Filter-Id {
- foreach &Calling-Station-Id {
- &reply += {
- &Called-Station-Id = "%{Foreach-Variable-0} %{Foreach-Variable-1}"
+foreach Filter-Id {
+ foreach Calling-Station-Id {
+ reply += {
+ Called-Station-Id = "%{Foreach-Variable-0} %{Foreach-Variable-1}"
}
}
}
# This is what most people end up using foreach for,
# so we should probably test it works.
-&cisco_prefix := "cisco"
+cisco_prefix := "cisco"
# Expanded regex
-foreach &Vendor-Specific.Cisco.AVPair {
+foreach Vendor-Specific.Cisco.AVPair {
if ("%{Foreach-Variable-0}" =~ /^%{cisco_prefix}=(.*)$/i) {
- &reply += {
- &Called-Station-Id = "%{1}"
+ reply += {
+ Called-Station-Id = "%{1}"
}
}
}
# Compiled regex
-foreach &Vendor-Specific.Cisco.AVPair {
+foreach Vendor-Specific.Cisco.AVPair {
if ("%{Foreach-Variable-0}" =~ /^stupid=(.*)$/i) {
- &reply += {
- &Called-Station-Id = "%{1}"
+ reply += {
+ Called-Station-Id = "%{1}"
}
}
}
#
# Adding attribute during request and immediately returning should still work
#
-&Filter-Id := { "1", "2", "3", "4", "5" }
+Filter-Id := { "1", "2", "3", "4", "5" }
-foreach &Filter-Id {
+foreach Filter-Id {
if ("%{Foreach-Variable-0}" == "3") {
success
# will prevent the "pap" module from being run
# in the "authorize" section.
#
- &control.Auth-Type := ::PAP
+ control.Auth-Type := ::PAP
#
# Stop processing "authorize", and go to the next section.
#
string out
-&Tmp-TLV-0 := {
- &a = 1
- &b = 2
- &c = "foo"
- &d = 127.0.0.1
+Tmp-TLV-0 := {
+ a = 1
+ b = 2
+ c = "foo"
+ d = 127.0.0.1
}
-&request += {
- &Tmp-TLV-0 = {
- &a = 2112
- &b = 6809
- &c = "bar"
- &d = 192.0.2.1
+request += {
+ Tmp-TLV-0 = {
+ a = 2112
+ b = 6809
+ c = "bar"
+ d = 192.0.2.1
}
}
-&out = ""
+out = ""
#
# Don't use "tlv" as the attribute name, because "tlv" is a data type.
#
-foreach thing (&Tmp-TLV-0[*]) {
- &out += &thing.c
- &out += " "
+foreach thing (Tmp-TLV-0[*]) {
+ out += thing.c
+ out += " "
}
-&out -= " "
+out -= " "
#
# And we have updated the string from multiple TLVs, and one particular
# child from each TLV.
#
-if (&out != 'foo bar') {
+if (out != 'foo bar') {
test_fail
}
-&request -= &Packet-Type
+request -= Packet-Type
#
# New syntax
#
-foreach thing ( &Filter-Id ) {
- &reply += {
- &Called-Station-Id = &thing
+foreach thing ( Filter-Id ) {
+ reply += {
+ Called-Station-Id = thing
}
}
#
# PRE: foreach
#
-&control += {
- &Filter-Id = "ssid=ABCDEF"
- &Filter-Id = "ssid=GHIJKL"
+control += {
+ Filter-Id = "ssid=ABCDEF"
+ Filter-Id = "ssid=GHIJKL"
}
-if (&User-Name) {
- foreach &control.Filter-Id {
+if (User-Name) {
+ foreach control.Filter-Id {
if ("%{Foreach-Variable-0}" =~ /(.*)/) {
- &control.Calling-Station-Id := "%{1}"
+ control.Calling-Station-Id := "%{1}"
}
}
}
-if (!(&control.Calling-Station-Id == 'ssid=GHIJKL')) {
+if (!(control.Calling-Station-Id == 'ssid=GHIJKL')) {
test_fail
}
-&control -= &Calling-Station-Id[*]
+control -= Calling-Station-Id[*]
-foreach &control.Filter-Id {
+foreach control.Filter-Id {
if ("%{Foreach-Variable-0}" =~ /(.*)/) {
- &control.Calling-Station-Id := "%{1}"
+ control.Calling-Station-Id := "%{1}"
}
}
-if (!(&control.Calling-Station-Id == 'ssid=GHIJKL')) {
+if (!(control.Calling-Station-Id == 'ssid=GHIJKL')) {
test_fail
}
-&control -= &Calling-Station-Id[*]
+control -= Calling-Station-Id[*]
success
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
+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
-&result_string := %hex(%{test_string})
-if (!(&result_string == '39383730')) {
+result_string := %hex(%{test_string})
+if (!(result_string == '39383730')) {
test_fail
}
# Octets
-&result_string := %hex(%{test_octets})
-if (!(&result_string == '39383731')) {
+result_string := %hex(%{test_octets})
+if (!(result_string == '39383731')) {
test_fail
}
# IP Address
-&result_string := %hex(%{test_ipaddr})
-if (!(&result_string == '39383732')) {
+result_string := %hex(%{test_ipaddr})
+if (!(result_string == '39383732')) {
test_fail
}
# Integer
-&result_string := %hex(%{test_integer})
-if (!(&result_string == '39383734')) {
+result_string := %hex(%{test_integer})
+if (!(result_string == '39383734')) {
test_fail
}
# ifid
-&result_string := %hex(%{test_ifid})
-if (!(&result_string == '0000000039383737')) {
+result_string := %hex(%{test_ifid})
+if (!(result_string == '0000000039383737')) {
test_fail
}
# ipv6addr
-&result_string := %hex(%{test_ipv6addr})
-if (!(&result_string == '00000000000000000000000039383738')) {
+result_string := %hex(%{test_ipv6addr})
+if (!(result_string == '00000000000000000000000039383738')) {
test_fail
}
# ipv6addrprefix
-&result_string := %hex(%{test_ipv6prefix})
-if (!(&result_string == '008000000000000000000000000039383739')) {
+result_string := %hex(%{test_ipv6prefix})
+if (!(result_string == '008000000000000000000000000039383739')) {
test_fail
}
# byte
-&result_string := %hex(%{test_byte})
-if (!(&result_string == '3a')) {
+result_string := %hex(%{test_byte})
+if (!(result_string == '3a')) {
test_fail
}
# short
-&result_string := %hex(%{test_short})
-if (!(&result_string == '373b')) {
+result_string := %hex(%{test_short})
+if (!(result_string == '373b')) {
test_fail
}
# ethernet
-&result_string := %hex(%{test_ether})
-if (!(&result_string == '00003938373c')) {
+result_string := %hex(%{test_ether})
+if (!(result_string == '00003938373c')) {
test_fail
}
# integer64
-&result_string := %hex(%{test_int64})
-if (!(&result_string == '100000003938373d')) {
+result_string := %hex(%{test_int64})
+if (!(result_string == '100000003938373d')) {
test_fail
}
# ipv4prefix
-&result_string := %hex(%{test_ipv4prefix})
-if (!(&result_string == '203938373e')) {
+result_string := %hex(%{test_ipv4prefix})
+if (!(result_string == '203938373e')) {
test_fail
}
-&request += {
- &Class = 0x0101
- &Class = 0x010203
- &Class = 0x0405
+request += {
+ Class = 0x0101
+ Class = 0x010203
+ Class = 0x0405
}
-&NAS-Identifier := %hex(%{Class[*]})
+NAS-Identifier := %hex(%{Class[*]})
-if (&NAS-Identifier[#] != 3) {
+if (NAS-Identifier[#] != 3) {
test_fail
}
-if !((&NAS-Identifier[0] == '0101') && (&NAS-Identifier[1] == '010203') && (&NAS-Identifier[2] == '0405')) {
+if !((NAS-Identifier[0] == '0101') && (NAS-Identifier[1] == '010203') && (NAS-Identifier[2] == '0405')) {
test_fail
}
# then fail in the compilation stage, because the
# attribute doesn't exist.
#
-if (&Not-Dynamically-Allocated) { # ERROR
+if (Not-Dynamically-Allocated) { # ERROR
# foo
}
#
# Matching "if" conditions
#
-if (&User-Name == "bob") {
+if (User-Name == "bob") {
success
}
-if (!(&User-Name == "bob")) {
+if (!(User-Name == "bob")) {
test_fail
}
#
# Matching "if" conditions
#
-if (!(&User-Name == "bob")) {
+if (!(User-Name == "bob")) {
test_fail
}
else {
#
# Matching "if" conditions
#
-if (!(&User-Name == "bob")) {
+if (!(User-Name == "bob")) {
test_fail
}
-elsif (&User-Name == "bob") {
+elsif (User-Name == "bob") {
success
}
else {
test_fail
}
-if (!(&Module-Failure-Message[*] == "No previous named regex capture group")) {
+if (!(Module-Failure-Message[*] == "No previous named regex capture group")) {
test_fail
}
}
group {
octets hash
- &hash = %md5('foo')
- if !(&hash == 0xacbd18db4cc2f85cedef654fccc4a4d8) {
+ hash = %md5('foo')
+ if !(hash == 0xacbd18db4cc2f85cedef654fccc4a4d8) {
test_fail
}
}
# PRE: if
#
-&request += {
- &Filter-Id = 'foo'
- &Filter-Id = 'bar'
- &Filter-Id = 'baz'
+request += {
+ Filter-Id = 'foo'
+ Filter-Id = 'bar'
+ Filter-Id = 'baz'
- &NAS-Port-Id = 'GROUP ADMINISTRATORS'
- &NAS-Port-Id = 'GROUP STUDENTS'
- &NAS-Port-Id = 'GROUP PEONS'
+ NAS-Port-Id = 'GROUP ADMINISTRATORS'
+ NAS-Port-Id = 'GROUP STUDENTS'
+ NAS-Port-Id = 'GROUP PEONS'
- &Reply-Message = 'PEONS'
- &Reply-Message = 'STUDENTS'
- &Reply-Message = 'ADMINISTRATORS'
+ Reply-Message = 'PEONS'
+ Reply-Message = 'STUDENTS'
+ Reply-Message = 'ADMINISTRATORS'
- &Callback-Id = 'no'
- &Callback-Id = 'no'
- &Callback-Id = 'yes'
+ Callback-Id = 'no'
+ Callback-Id = 'no'
+ Callback-Id = 'yes'
- &NAS-Port = 1
- &NAS-Port = 2
- &NAS-Port = 5
+ NAS-Port = 1
+ NAS-Port = 2
+ NAS-Port = 5
}
-&control += {
- &Filter-Id = 'foo'
- &Filter-Id = 'bar'
- &Filter-Id = 'baz'
+control += {
+ Filter-Id = 'foo'
+ Filter-Id = 'bar'
+ Filter-Id = 'baz'
- &NAS-Port-Id = 'boink'
- &NAS-Port-Id = 'tard'
- &NAS-Port-Id = 'dink'
- &NAS-Port-Id = 'slink'
+ NAS-Port-Id = 'boink'
+ NAS-Port-Id = 'tard'
+ NAS-Port-Id = 'dink'
+ NAS-Port-Id = 'slink'
- &NAS-Port = 01
- &NAS-Port = 02
- &NAS-Port = 05
- &NAS-Port = 04
+ NAS-Port = 01
+ NAS-Port = 02
+ NAS-Port = 05
+ NAS-Port = 04
- &Port-Limit = 10
- &Port-Limit = 20
- &Port-Limit = 30
+ Port-Limit = 10
+ Port-Limit = 20
+ Port-Limit = 30
}
#
# Mmmm O(N^2)
#
-if (!(&Filter-Id[*] == &control.Filter-Id[*])) {
+if (!(Filter-Id[*] == control.Filter-Id[*])) {
test_fail
}
-if (&Filter-Id[*] == &control.NAS-Port-Id[*]) {
+if (Filter-Id[*] == control.NAS-Port-Id[*]) {
test_fail
}
-if (&NAS-Port-Id[*] == &control.Filter-Id[*]) {
+if (NAS-Port-Id[*] == control.Filter-Id[*]) {
test_fail
}
#
# Integer comparison and normalisation
#
-if (!(&NAS-Port == &control.NAS-Port)) {
+if (!(NAS-Port == control.NAS-Port)) {
test_fail
}
# if any value of request.NAS-Port > any value of
# request.Port-Limit then evaluate to true
#
-if (&NAS-Port[*] > &control.Port-Limit[*]) {
+if (NAS-Port[*] > control.Port-Limit[*]) {
test_fail
}
#
# Compiled regex comparisons
#
-if (&NAS-Port-Id[*] !~ /PEONS$/) {
+if (NAS-Port-Id[*] !~ /PEONS$/) {
test_fail
}
-if (&control.NAS-Port-Id =~ /PEONS$/) {
+if (control.NAS-Port-Id =~ /PEONS$/) {
test_fail
}
-if (&control.NAS-Port-Id =~ /DINKS$/) {
+if (control.NAS-Port-Id =~ /DINKS$/) {
test_fail
}
#
# Dynamic regex comparisons
#
-if (&NAS-Port-Id[*] !~ /%{Reply-Message[0]}$/) {
+if (NAS-Port-Id[*] !~ /%{Reply-Message[0]}$/) {
test_fail
}
-if (&NAS-Port-Id =~ /%{Reply-Message[1]}$/) {
+if (NAS-Port-Id =~ /%{Reply-Message[1]}$/) {
test_fail
}
-if !(&NAS-Port-Id =~ /%{Reply-Message[2]}$/) {
+if !(NAS-Port-Id =~ /%{Reply-Message[2]}$/) {
test_fail
}
-if (&NAS-Port-Id =~ /%{Reply-Message[#]}$/) {
+if (NAS-Port-Id =~ /%{Reply-Message[#]}$/) {
test_fail
}
#
# XLAT virtual comparisons
#
-if (!(&control.NAS-Port[*] == %{control.NAS-Port[#]})) {
+if (!(control.NAS-Port[*] == %{control.NAS-Port[#]})) {
test_fail
}
#
# Literal comparisons
#
-if (!(&control.NAS-Port-Id[*] == 'boink')) {
+if (!(control.NAS-Port-Id[*] == 'boink')) {
test_fail
}
-if (&control.NAS-Port-Id[*] == 'foo') {
+if (control.NAS-Port-Id[*] == 'foo') {
test_fail
}
-if (&NAS-Port[*] > 10) {
+if (NAS-Port[*] > 10) {
test_fail
}
-if (!(&NAS-Port[*] < 10)) {
+if (!(NAS-Port[*] < 10)) {
test_fail
}
# PRE: if
#
-&request += {
- &Filter-Id = 'foo'
- &Filter-Id = 'bar'
+request += {
+ Filter-Id = 'foo'
+ Filter-Id = 'bar'
}
-if !(&NAS-Port || &Filter-Id) {
+if !(NAS-Port || Filter-Id) {
test_fail
}
-if !(!(!(&Filter-Id))) {
+if !(!(!(Filter-Id))) {
test_fail
}
-if (&Filter-Id[0] && &Filter-Id[1] && &Filter-Id[2]) {
+if (Filter-Id[0] && Filter-Id[1] && Filter-Id[2]) {
test_fail
}
-if !(((&Filter-Id[0] == 'baz') && (&Filter-Id[1] == 'boing')) || ((&Filter-Id[0] == 'foo') && (&Filter-Id[1] == 'bar'))) {
+if !(((Filter-Id[0] == 'baz') && (Filter-Id[1] == 'boing')) || ((Filter-Id[0] == 'foo') && (Filter-Id[1] == 'bar'))) {
test_fail
}
-if !(((&Filter-Id[0] == 'foo') && (&Filter-Id[1] == 'boing')) || ((&Filter-Id[0] == 'foo') && (&Filter-Id[1] == 'bar'))) {
+if !(((Filter-Id[0] == 'foo') && (Filter-Id[1] == 'boing')) || ((Filter-Id[0] == 'foo') && (Filter-Id[1] == 'bar'))) {
test_fail
}
-if !((&NAS-Port || &Filter-Id) && (&Calling-Station-Id || &User-Name)) {
+if !((NAS-Port || Filter-Id) && (Calling-Station-Id || User-Name)) {
test_fail
}
-if !(((&NAS-Port || &Filter-Id) && !&User-Name) || (&Calling-Station-Id || &User-Name)) {
+if !(((NAS-Port || Filter-Id) && !User-Name) || (Calling-Station-Id || User-Name)) {
test_fail
}
#
# return code in an "if" section.
#
-if (&User-Name == "bob") {
+if (User-Name == "bob") {
ok = reject # ERROR
}
#
# This should parse
#
-if (&User-Name =~ /%{User-Name}/) {
+if (User-Name =~ /%{User-Name}/) {
ok
}
#
# Check regexes which refer to unknown attributes
#
-if (&User-Name =~ /%{What-The-Heck-Is-This-Thing}/) { # ERROR
+if (User-Name =~ /%{What-The-Heck-Is-This-Thing}/) { # ERROR
ok
}
# PRE: if if-regex-match
#
-if !(&control.Password.Cleartext =~ /hell(o)(.*)/) {
+if !(control.Password.Cleartext =~ /hell(o)(.*)/) {
test_fail
}
test_fail
}
-if !(&control.Password.Cleartext =~ /hello(.*)/) {
+if !(control.Password.Cleartext =~ /hello(.*)/) {
test_fail
}
#
# Check assignment of regex null-match
#
-if (&control.Password.Cleartext =~ /hell(o)(.*)/) {
- &control.Filter-Id := "%{2}"
+if (control.Password.Cleartext =~ /hell(o)(.*)/) {
+ control.Filter-Id := "%{2}"
}
-if (!&control.Filter-Id) {
+if (!control.Filter-Id) {
test_fail
}
-if (!(&control.Filter-Id == "")) {
+if (!(control.Filter-Id == "")) {
test_fail
}
#
# Check that bad regular expressions will fail
#
-if (&User-Name =~ /[a-3]/) { # ERROR
+if (User-Name =~ /[a-3]/) { # ERROR
ok
}
string dummy_string
uint32 test_integer
-&test_integer := '123456789'
+test_integer := '123456789'
# Non matching on attribute ref
-if !(&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{test_string}/) {
+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])%{test_string}/) {
+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}"
+ reply.User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
}
else {
test_fail
}
# Checking capture groups are cleared out correctly
-if (&User-Name =~ /^([0-9])_%{test_string}/) {
+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 =~ /^.%{test_string}/) {
+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%{test_string}$/i) {
+if !(Calling-Station-Id =~ /:roamyroam%{test_string}$/i) {
test_fail
}
# uncompiled - expansion - insensitive
-if !(&Calling-Station-Id =~ /:roamyroam%{test_string}$/i) {
+if !(Calling-Station-Id =~ /:roamyroam%{test_string}$/i) {
test_fail
}
# uncompiled - enum - ref - insensitive
-if !(&Service-Type =~ /^framed-user%{test_string}$/i) {
+if !(Service-Type =~ /^framed-user%{test_string}$/i) {
test_fail
}
}
# uncompiled - enum - ref
-if (&Service-Type =~ /^framed-user%{test_string}$/) {
+if (Service-Type =~ /^framed-user%{test_string}$/) {
test_fail
}
# uncompiled - integer - ref
-if !(&test_integer =~ /%{test_integer}/) {
+if !(test_integer =~ /%{test_integer}/) {
test_fail
}
-&test_string := "foo\nbar"
+test_string := "foo\nbar"
# uncompiled - ref - multiline
-if !(&test_string =~ /^foo$%{dummy_string}/m) {
+if !(test_string =~ /^foo$%{dummy_string}/m) {
test_fail
}
# uncompiled - ref - non-multiline
-if (&test_string =~ /^foo$%{dummy_string}/) {
+if (test_string =~ /^foo$%{dummy_string}/) {
test_fail
}
# uncompiled - ref - non-multiline
-if !(&test_string =~ /^foo\nbar%{dummy_string}$/) {
+if !(test_string =~ /^foo\nbar%{dummy_string}$/) {
test_fail
}
# uncompiled - ref - multiline
-if !(&test_string =~ /^bar%{dummy_string}$/m) {
+if !(test_string =~ /^bar%{dummy_string}$/m) {
test_fail
}
# uncompiled - ref - multiline - sensitive
-if (&test_string =~ /^BAR%{dummy_string}$/m) {
+if (test_string =~ /^BAR%{dummy_string}$/m) {
test_fail
}
# uncompiled - ref - multiline - insensitive
-if !(&test_string =~ /^BAR%{dummy_string}$/mi) {
+if !(test_string =~ /^BAR%{dummy_string}$/mi) {
test_fail
}
# uncompiled - ref - multiline - insensitive (flag order reversed)
-if !(&test_string =~ /^BAR%{dummy_string}$/im) {
+if !(test_string =~ /^BAR%{dummy_string}$/im) {
test_fail
}
string test_string
# Non matching on attribute ref
-if !(&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
+if !(User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
test_fail
}
}
# Matching on attribute ref with capture groups
-if (&User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
+if (User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
# Test all the capture groups
- &reply.User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
+ reply.User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
}
else {
test_fail
}
# Checking capture groups are cleared out correctly
-if (&User-Name =~ /^([0-9])_/) {
+if (User-Name =~ /^([0-9])_/) {
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 =~ /^./) {
+if (User-Name =~ /^./) {
if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1')) {
test_fail
}
}
# compiled - ref - insensitive
-if !(&Calling-Station-Id =~ /:roamyroam$/i) {
+if !(Calling-Station-Id =~ /:roamyroam$/i) {
test_fail
}
# compiled - expansion - insensitive
-if !(&Calling-Station-Id =~ /:roamyroam$/i) {
+if !(Calling-Station-Id =~ /:roamyroam$/i) {
test_fail
}
# compiled - enum - ref - insensitive
-if !(&Service-Type =~ /^framed-user$/i) {
+if !(Service-Type =~ /^framed-user$/i) {
test_fail
}
}
# compiled - enum - ref
-if (&Service-Type =~ /^framed-user$/) {
+if (Service-Type =~ /^framed-user$/) {
test_fail
}
-&test_string := "foo\nbar"
+test_string := "foo\nbar"
# compiled - ref - multiline
-if !(&test_string =~ /^foo$/m) {
+if !(test_string =~ /^foo$/m) {
test_fail
}
# compiled - ref - non-multiline
-if (&test_string =~ /^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')) && !(&test_string =~ /^foo\nbar$/)) {
+if ((('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) && !(test_string =~ /^foo\nbar$/)) {
test_fail
}
# compiled - ref - multiline
-if !(&test_string =~ /^bar$/m) {
+if !(test_string =~ /^bar$/m) {
test_fail
}
# compiled - ref - multiline - sensitive
-if (&test_string =~ /^BAR$/m) {
+if (test_string =~ /^BAR$/m) {
test_fail
}
# compiled - ref - multiline - insensitive
-if !(&test_string =~ /^BAR$/mi) {
+if !(test_string =~ /^BAR$/mi) {
test_fail
}
# compiled - ref - multiline - insensitive (flag order reversed)
-if !(&test_string =~ /^BAR$/im) {
+if !(test_string =~ /^BAR$/im) {
test_fail
}
string dummy_string
if (('${feature.regex-pcre}' == 'yes') || ('${feature.regex-pcre2}' == 'yes')) {
- &request += {
- &NAS-Port = '123456789'
- &Port-Limit = 1
+ request += {
+ NAS-Port = '123456789'
+ Port-Limit = 1
}
# Check failure when no previous capture - full capture
test_fail
}
-if (!(&Module-Failure-Message[*] == "No previous regex capture")) {
+if (!(Module-Failure-Message[*] == "No previous regex capture")) {
test_fail
}
-&request -= &Module-Failure-Message[*]
+request -= Module-Failure-Message[*]
# Check failure when no previous capture - named group
if (%regex(foo)) {
test_fail
}
-if (!(&Module-Failure-Message[*] == "No previous named regex capture group")) {
+if (!(Module-Failure-Message[*] == "No previous named regex capture group")) {
test_fail
}
-&request -= &Module-Failure-Message[*]
+request -= Module-Failure-Message[*]
# Check failure when no previous capture - numbered group
if (%regex(%{Port-Limit})) {
test_fail
}
-if (!(&Module-Failure-Message[*] == "No previous numbered regex capture group")) {
+if (!(Module-Failure-Message[*] == "No previous numbered regex capture group")) {
test_fail
}
-&request -= &Module-Failure-Message[*]
+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])%{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')) {
+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])_%{dummy_string}/) {
- &result_string := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)"
- if (!(&result_string == '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 =~ /^.%{dummy_string}/) {
- &result_string := "%{0}%regex(one)%regex(two)%regex(three)%regex(four)%regex(five)%regex(six)%regex(seven)"
- if (!(&result_string == '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])/) {
- &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')) {
+if (User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
+ 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])/) {
- &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')) {
+ 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])/) {
- &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')) {
+if (User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
+ 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])/) {
+if (User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
uint32 a
uint32 b
uint32 c
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')) {
+ 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
}
}
# PRE: update if
#
-&Vendor-Specific.Cisco.AVPair := { 'foo=bar', 'bar=baz', 'baz=foo' }
+Vendor-Specific.Cisco.AVPair := { 'foo=bar', 'bar=baz', 'baz=foo' }
-if (&Vendor-Specific.Cisco.AVPair[1] =~ /bar=(.*)/) {
+if (Vendor-Specific.Cisco.AVPair[1] =~ /bar=(.*)/) {
if (!("%{1}" == 'baz')) {
test_fail
}
test_fail
}
-if (&Vendor-Specific.Cisco.AVPair[*] =~ /bar=(.*)/) {
+if (Vendor-Specific.Cisco.AVPair[*] =~ /bar=(.*)/) {
if (!("%{1}" == 'baz')) {
test_fail
}
#
# PRE: if
#
-if !(&User-Name =~ /^\0/) {
+if !(User-Name =~ /^\0/) {
success
} else {
test_fail
# PRE: if
#
-%map("&TLS-Certificate.Issuer = 'foo'")
+%map("TLS-Certificate.Issuer = 'foo'")
-if !(&TLS-Certificate.Issuer == 'foo') {
+if !(TLS-Certificate.Issuer == 'foo') {
test_fail
}
#
uint32 test_integer
-&NAS-Port := 1812
+NAS-Port := 1812
#
# Editing it is fine.
#
-&NAS-Port += 1
-if !(&NAS-Port == 1813) {
+NAS-Port += 1
+if !(NAS-Port == 1813) {
test_fail
}
#
# Mark it as immutable. The value shouldn't change.
#
-%immutable(&request.NAS-Port[*])
-if !(&NAS-Port == 1813) {
+%immutable(request.NAS-Port[*])
+if !(NAS-Port == 1813) {
test_fail
}
# Try to edit it. The value shouldn't change.
#
transaction {
- &NAS-Port += 1
+ NAS-Port += 1
}
-if !(&NAS-Port == 1813) {
+if !(NAS-Port == 1813) {
test_fail
}
#
# We can't delete it. Deletion is a noop
#
-&request -= &NAS-Port[*]
-if !(&NAS-Port == 1813) {
+request -= NAS-Port[*]
+if !(NAS-Port == 1813) {
test_fail
}
#
# We can copy the immutable value. The copy is mutable.
#
-&test_integer := &NAS-Port
-if !(&test_integer == 1813) {
+test_integer := NAS-Port
+if !(test_integer == 1813) {
test_fail
}
-&test_integer += 1
-if !(&test_integer == 1814) {
+test_integer += 1
+if !(test_integer == 1814) {
test_fail
}
#
# Add a non-immutable NAS-Port
#
-&request += {
- &NAS-Port = 6809
+request += {
+ NAS-Port = 6809
}
-if !(&NAS-Port[1] == 6809) {
+if !(NAS-Port[1] == 6809) {
test_fail
}
# Deleting all NAS-Port attributes means that we delete the _mutable_
# ones, and leave the _immutable_ ones in place.
#
-&request -= &NAS-Port[*]
-if !(&NAS-Port == 1813) {
+request -= NAS-Port[*]
+if !(NAS-Port == 1813) {
test_fail
}
-if (&NAS-Port[#] != 1) {
+if (NAS-Port[#] != 1) {
test_fail
}
#
ipaddr result_ipaddr
-if (!(&NAS-IP-Address == 127.0.0.1)) {
+if (!(NAS-IP-Address == 127.0.0.1)) {
test_fail
}
# Dotted Quad
-&result_ipaddr := 127.0.0.1
-if (!(&result_ipaddr == 127.0.0.1)) {
+result_ipaddr := 127.0.0.1
+if (!(result_ipaddr == 127.0.0.1)) {
test_fail
}
# Dotted Quad with prefix
-&result_ipaddr := 127.0.0.2/32
-if (!(&result_ipaddr == 127.0.0.2)) {
+result_ipaddr := 127.0.0.2/32
+if (!(result_ipaddr == 127.0.0.2)) {
test_fail
}
# Hex (0x)
-&result_ipaddr := 0x7f000003
-if (!(&result_ipaddr == 127.0.0.3)) {
+result_ipaddr := 0x7f000003
+if (!(result_ipaddr == 127.0.0.3)) {
test_fail
}
# Decimal
-&result_ipaddr := 2130706436
-if (!(&result_ipaddr == 127.0.0.4)) {
+result_ipaddr := 2130706436
+if (!(result_ipaddr == 127.0.0.4)) {
test_fail
}
#
# Malformed NAS-IP-Address
#
-&raw.4 = 0x010203
+raw.4 = 0x010203
-if (!&raw.4) {
+if (!raw.4) {
test_fail
}
-elsif (!(&raw.4 == 0x010203)) {
+elsif (!(raw.4 == 0x010203)) {
test_fail
}
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
+test_ipv4prefix := 198.51.100.255/16
+test_ipv6prefix := ::198.51.100.255/112
+Framed-IP-Address := 198.51.0.1
-if (!(&test_ipv6prefix == '::198.51.0.0/112')) {
+if (!(test_ipv6prefix == '::198.51.0.0/112')) {
test_fail
}
-if (!(&test_ipv4prefix == '198.51.0.0/16')) {
+if (!(test_ipv4prefix == '198.51.0.0/16')) {
test_fail
}
-if (!(&test_ipv6prefix == ::198.51.0.0/112)) {
+if (!(test_ipv6prefix == ::198.51.0.0/112)) {
test_fail
}
-if (!(&test_ipv4prefix == 198.51.0.0/16)) {
+if (!(test_ipv4prefix == 198.51.0.0/16)) {
test_fail
}
-if (!(&test_ipv4prefix < 198.0.0.0/8)) {
+if (!(test_ipv4prefix < 198.0.0.0/8)) {
test_fail
}
-if (!(&Framed-IP-Address < 198.51.0.0/16)) {
+if (!(Framed-IP-Address < 198.51.0.0/16)) {
test_fail
}
#
string result_string
-&control -= &Password[*]
-
-&control += {
- &User-Name = &request.User-Name
- &User-Password = &request.User-Password
- &Filter-Id = "ab c"
- &Filter-Id = "de fg"
- &NAS-Port = 123
+control -= Password[*]
+
+control += {
+ User-Name = request.User-Name
+ User-Password = request.User-Password
+ Filter-Id = "ab c"
+ Filter-Id = "de fg"
+ NAS-Port = 123
}
-&request.Framed-IP-Address := 192.168.1.254
+request.Framed-IP-Address := 192.168.1.254
debug_control
debug_request
#
# @todo - fix this...
#
-&result_string := %concat(%join(%{control.[*]}, %{request.Framed-IP-Address}), '. ')
+result_string := %concat(%join(%{control.[*]}, %{request.Framed-IP-Address}), '. ')
-if (!(&result_string == "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
}
-&result_string := %concat(%join(%{control.Filter-Id[*]}, %{control.NAS-Port}), ',')
-if (!(&result_string == "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
}
ipv4prefix test_ipv4prefix
uint32 result_int
-&test_string := '\
+test_string := '\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
test_fail
}
-&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
+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
-&result_int := %length(%{test_string})
-if (!(&result_int == 4)) {
+result_int := %length(%{test_string})
+if (!(result_int == 4)) {
test_fail
}
# Octets - bin 0x39383731
-&result_int := %length(%{test_octets})
-if (!(&result_int == 4)) {
+result_int := %length(%{test_octets})
+if (!(result_int == 4)) {
test_fail
}
# IP Address - bin 0x39383732
-&result_int := %length(%{test_ipaddr})
-if (!(&result_int == 4)) {
+result_int := %length(%{test_ipaddr})
+if (!(result_int == 4)) {
test_fail
}
# String - "hello, world"
-&result_int := %length('hello, world')
-if (!(&result_int == 12)) {
+result_int := %length('hello, world')
+if (!(result_int == 12)) {
test_fail
}
# Integer - bin 0x39383734
-&result_int := %length(%{test_integer})
-if (!(&result_int == 4)) {
+result_int := %length(%{test_integer})
+if (!(result_int == 4)) {
test_fail
}
# ifid - bin 0x0000000039383737
-&result_int := %length(%{test_ifid})
-if (!(&result_int == 8)) {
+result_int := %length(%{test_ifid})
+if (!(result_int == 8)) {
test_fail
}
# ipv6addr - bin 0x00000000000000000000000039383738
-&result_int := %length(%{test_ipv6addr})
-if (!(&result_int == 16)) {
+result_int := %length(%{test_ipv6addr})
+if (!(result_int == 16)) {
test_fail
}
# ipv6addrprefix - bin 0x8000000000000000000000000039383739
-&result_int := %length(%{test_ipv6prefix})
-if (!(&result_int == 17)) {
+result_int := %length(%{test_ipv6prefix})
+if (!(result_int == 17)) {
test_fail
}
# byte - bin 0x3a
-&result_int := %length(%{test_byte})
-if (!(&result_int == 1)) {
+result_int := %length(%{test_byte})
+if (!(result_int == 1)) {
test_fail
}
# short - bin 0x373b
-&result_int := %length(%{test_short})
-if (!(&result_int == 2)) {
+result_int := %length(%{test_short})
+if (!(result_int == 2)) {
test_fail
}
# ethernet - bin 0x00003938373c
-&result_int := %length(%{test_ether})
-if (!(&result_int == 6)) {
+result_int := %length(%{test_ether})
+if (!(result_int == 6)) {
test_fail
}
# integer64 - bin 0x100000003938373d
-&result_int := %length(%{test_int64})
-if (!(&result_int == 8)) {
+result_int := %length(%{test_int64})
+if (!(result_int == 8)) {
test_fail
}
# ipv4prefix - bin 0x203938373e
-&result_int := %length(%{test_ipv4prefix})
-if (!(&result_int == 5)) {
+result_int := %length(%{test_ipv4prefix})
+if (!(result_int == 5)) {
test_fail
}
group foo
-&foo := &request + &control # ERROR
+foo := request + control # ERROR
#
# List existence checks are "is the list empty" checks.
#
-if (&session-state.) {
+if (session-state.) {
test_fail
}
-if (&session-state.[*]) {
+if (session-state.[*]) {
test_fail
}
-if (&session-state.) {
+if (session-state.) {
test_fail
}
-&session-state.User-Name := 'foo'
+session-state.User-Name := 'foo'
-if (!&session-state.) {
+if (!session-state.) {
test_fail
}
-if (!&session-state.[*]) {
+if (!session-state.[*]) {
test_fail
}
uint32 count1
uint32 count2
-&count1 := 0
-&count2 := 0
+count1 := 0
+count2 := 0
-&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
+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 &NAS-Port {
+foreach NAS-Port {
load-balance {
group {
- &count1 += 1
- &request += {
- &Reply-Message = "Picked group 1 - %{count1} time(s)"
+ count1 += 1
+ request += {
+ Reply-Message = "Picked group 1 - %{count1} time(s)"
}
ok
}
group {
- &count2 += 1
- &request += {
- &Reply-Message = "Picked group 2 %{count2} Time(s)"
+ count2 += 1
+ request += {
+ 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 ((&count1 == 0) || (&count2 == 0)) {
+if ((count1 == 0) || (count2 == 0)) {
test_fail
}
-if !(&count1 + &count2 == 50) {
+if !(count1 + count2 == 50) {
test_fail
}
uint32 foo
# There's only one local variable
- &foo[1] := 1 # ERROR
+ foo[1] := 1 # ERROR
}
group {
uint32 foo
- &foo := 1
+ foo := 1
debug_request
- &request -= &foo # ERROR
+ request -= foo # ERROR
debug_request
}
group {
uint32 foo
- &request.foo := 1 # ERROR
+ request.foo := 1 # ERROR
}
-&Filter-Id := 2
+Filter-Id := 2
-if !(&request.[#] == 5) {
+if !(request.[#] == 5) {
debug_request
test_fail
}
# We declared it, but it does *not* exist until we assign
# a value to it.
#
- if &foo {
+ if foo {
test_fail
}
- &foo := 1
+ foo := 1
- &Filter-Id := &foo
+ Filter-Id := foo
- if !(&Filter-Id == &foo) {
+ if !(Filter-Id == foo) {
test_fail
}
#
# Local variables are *not* in the request.
#
- if !(&request.[#] == 5) {
+ if !(request.[#] == 5) {
test_fail
}
#
# Local variables can be expanded
#
- &Reply-Message := "This is %{foo}"
- if !(&Reply-Message == "This is 1") {
+ Reply-Message := "This is %{foo}"
+ if !(Reply-Message == "This is 1") {
test_fail
}
- &request -= &Reply-Message
+ request -= Reply-Message
-} # leaving this scope automatically deletes &foo
+} # leaving this scope automatically deletes foo
-if !(&request.[#] == 5) {
+if !(request.[#] == 5) {
debug_request
test_fail
}
-if !(&Filter-Id == "1") {
+if !(Filter-Id == "1") {
test_fail
}
uint32 test_integer1
uint32 test_integer2
-&test_integer1 := 0
-&test_integer2 := 1
+test_integer1 := 0
+test_integer2 := 1
#
# (true && true) --> true
#
# But if it's false, then we have an issue.
#
-if !((&test_integer1 == 0) && (&test_integer2 == 1)) {
+if !((test_integer1 == 0) && (test_integer2 == 1)) {
test_fail
}
#
# false && true --> false
#
-if ((&test_integer1 == 1) && (&test_integer2 == 1)) {
+if ((test_integer1 == 1) && (test_integer2 == 1)) {
test_fail
}
#
# true && false -> false
#
-if ((&test_integer1 == 0) && (&test_integer2 == 0)) {
+if ((test_integer1 == 0) && (test_integer2 == 0)) {
test_fail
}
-&control.Filter-Id := { "bob", "oof" }
+control.Filter-Id := { "bob", "oof" }
-if ((&control.Filter-Id[0] == 'bob') && (&control.Filter-Id[1] == 'oof')) {
+if ((control.Filter-Id[0] == 'bob') && (control.Filter-Id[1] == 'oof')) {
# OK
} else {
test_fail
uint32 test_integer1
uint32 test_integer2
-&test_integer1 := 0
-&test_integer2 := 1
+test_integer1 := 0
+test_integer2 := 1
-if !((&test_integer1 == 1) || (&test_integer2 == 1)) {
+if !((test_integer1 == 1) || (test_integer2 == 1)) {
test_fail
}
-if !((&test_integer2 == 1) || (&test_integer1 == 1)) {
+if !((test_integer2 == 1) || (test_integer1 == 1)) {
test_fail
}
#
# Neither of these exists, so the resulting string should be empty
#
-&Filter-Id := "%{&NAS-Port-Id || &NAS-Port-Id}"
+Filter-Id := "%{NAS-Port-Id || NAS-Port-Id}"
-if !(&Filter-Id == '') {
+if !(Filter-Id == '') {
test_fail
}
string foo
-&Acct-Session-Time = 30
+Acct-Session-Time = 30
#
# Test for short-circuit logical optimizations
#
-&foo = %{&Acct-Session-Time || 'NULL'}
+foo = %{Acct-Session-Time || 'NULL'}
-if !(&foo == "30") {
+if !(foo == "30") {
test_fail
}
success
#
# PRE: map-2arg-error map-empty-error map-module-error map-field-error
#
-map csv &User-Name {
- &CSV-Result := field3
+map csv User-Name {
+ CSV-Result := field3
}
-if (!(&CSV-Result == "success")) {
+if (!(CSV-Result == "success")) {
test_fail
}
# arg3 can be an xlat
#
map csv "%tolower(%{User-Name})" {
- &reply.Result-Status := 'field3'
+ reply.Result-Status := 'field3'
}
#
map csv "%tolower(%{User-Name})" {
- &reply.Result-Status := 'field3'
+ reply.Result-Status := 'field3'
}
# PRE: map
#
-&control.Filter-Id := "fail"
+control.Filter-Id := "fail"
-map csv &User-Name {
- &control.Filter-Id ^= 'field3'
+map csv User-Name {
+ control.Filter-Id ^= 'field3'
}
-if (!(&control.Filter-Id[0] == 'success')) {
+if (!(control.Filter-Id[0] == 'success')) {
test_fail
}
-if (!(&control.Filter-Id[1] == "fail")) {
+if (!(control.Filter-Id[1] == "fail")) {
test_fail
}
#
# PRE: map-2arg-error map-empty-error map-module-error
#
-map csv &User-Name {
+map csv User-Name {
reply.Filter-Id := 'field2' # ERROR
}
# PRE: map-2arg-error
#
map foo "bar" { # ERROR
- &User-Name = 'foo'
+ User-Name = 'foo'
}
#
# Test the map xlat
#
-&request += {
- &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'"
+request += {
+ 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(%{Filter-Id})" == 1)) {
test_fail
}
-if (!(&control.Filter-Id == 'testing123')) {
+if (!(control.Filter-Id == 'testing123')) {
test_fail
}
-foreach &NAS-Port-Id[*] {
+foreach NAS-Port-Id[*] {
if (!("%map(%{Foreach-Variable-0})" == 1)) {
test_fail
}
}
-if (!(&Vendor-Specific.Nokia-SR.MSAP-Interface[0] == 'UNICAST_7360OLT3')) {
+if (!(Vendor-Specific.Nokia-SR.MSAP-Interface[0] == 'UNICAST_7360OLT3')) {
test_fail
}
-if (!(&Vendor-Specific.Nokia-SR.MSAP-Interface[1] == 'UNICAST_7360OLT4')) {
+if (!(Vendor-Specific.Nokia-SR.MSAP-Interface[1] == 'UNICAST_7360OLT4')) {
test_fail
}
#
# Test the map xlat
#
-&Filter-Id := "request.Tmp-Group-0.User-Name = 'testing123'"
+Filter-Id := "request.Tmp-Group-0.User-Name = 'testing123'"
if (!("%map(%{Filter-Id})" == 1)) {
test_fail
#
# Test the map xlat
#
-&Filter-Id := "request.Tmp-Group-0.Filter-Id := 'testing123'"
+Filter-Id := "request.Tmp-Group-0.Filter-Id := 'testing123'"
if (!(%map("%{Filter-Id}") == 1)) {
test_fail
test_fail
}
-if (!&Tmp-Group-0[0].Filter-Id || (!(&Tmp-Group-0[0].Filter-Id == 'testing123'))) {
+if (!Tmp-Group-0[0].Filter-Id || (!(Tmp-Group-0[0].Filter-Id == 'testing123'))) {
test_fail
}
-if (!&Tmp-Group-0[0].User-Name || (!(&Tmp-Group-0[0].User-Name == 'testing000'))) {
+if (!Tmp-Group-0[0].User-Name || (!(Tmp-Group-0[0].User-Name == 'testing000'))) {
test_fail
}
#
string test_string
-&test_string := "IA-PD.IAID = 11"
+test_string := "IA-PD.IAID = 11"
if (!("%map(%{test_string})" == 1)) {
test_fail
}
-if (!&IA-PD.IAID) {
+if (!IA-PD.IAID) {
test_fail
}
-if (!(&IA-PD.IAID == 11)) {
+if (!(IA-PD.IAID == 11)) {
test_fail
}
octets test_octets
octets result_octets
-&test_string := "This is a string\n"
-&test_octets := 0x000504030201
+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.
#
-&result_octets := %md4("This is a string\n")
-if (!(&result_octets == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
+result_octets := %md4("This is a string\n")
+if (!(result_octets == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
test_fail
}
-&result_octets := %md4("%{test_string}")
-if (!(&result_octets == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
+result_octets := %md4("%{test_string}")
+if (!(result_octets == 0x1f60d5cd85e17bfbdda7c923822f060c)) {
test_fail
}
#
# MD4 should also be able to cope with references to octet attributes
#
-&result_octets := %md4("%{test_octets}")
-if (!(&result_octets == 0xac3ed17b3cf19ec38352ec534a932fc6)) {
+result_octets := %md4("%{test_octets}")
+if (!(result_octets == 0xac3ed17b3cf19ec38352ec534a932fc6)) {
test_fail
}
#
# MD4 of null string is d41d8cd98f00b204e9800998ecf8427e
#
-&result_octets := %md4("%{dummy_string}")
-if (!(&result_octets == 0x31d6cfe0d16ae931b73c59d7e0c089c0)) {
+result_octets := %md4("%{dummy_string}")
+if (!(result_octets == 0x31d6cfe0d16ae931b73c59d7e0c089c0)) {
test_fail
}
octets test_octets
octets result_octets
-&test_string := "This is a string\n"
-&test_octets := 0x000504030201
-&test_hmac_key := "what do ya want for nothing?"
-&test_hmac_data := "Jefe"
+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.
#
-&result_octets := %md5("This is a string\n")
-if (!(&result_octets == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
+result_octets := %md5("This is a string\n")
+if (!(result_octets == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
test_fail
}
-&result_octets := %md5("%{test_string}")
-if (!(&result_octets == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
+result_octets := %md5("%{test_string}")
+if (!(result_octets == 0x9ac4dbbc3c0ad2429e61d0df5dc28add)) {
test_fail
}
#
# MD5 should also be able to cope with references to octet attributes
#
-&result_octets := %md5("%{test_octets}")
-if (!(&result_octets == 0xc1e7fa505b2fc1fd0da6cac3db6f6f44)) {
+result_octets := %md5("%{test_octets}")
+if (!(result_octets == 0xc1e7fa505b2fc1fd0da6cac3db6f6f44)) {
test_fail
}
#
# MD5 of null string is d41d8cd98f00b204e9800998ecf8427e
#
-&result_octets := %md5("%{dummy_string}")
-if (!(&result_octets == 0xd41d8cd98f00b204e9800998ecf8427e)) {
+result_octets := %md5("%{dummy_string}")
+if (!(result_octets == 0xd41d8cd98f00b204e9800998ecf8427e)) {
test_fail
}
#
# MD5 HMAC with attribute references
#
-&result_octets := %hmacmd5("%{test_hmac_key}", "%{test_hmac_data}")
-if (!(&result_octets == 0x750c783e6ab0b503eaa86e310a5db738)) {
+result_octets := %hmacmd5("%{test_hmac_key}", "%{test_hmac_data}")
+if (!(result_octets == 0x750c783e6ab0b503eaa86e310a5db738)) {
test_fail
}
#
# MD5 HMAC with empty key and data
#
-&dummy_string := ''
-&result_octets := %hmacmd5("%{dummy_string}", "%{dummy_string}")
-if (!(&result_octets == 0x74e6f7298a9c2d168935f58c001bad88)) {
+dummy_string := ''
+result_octets := %hmacmd5("%{dummy_string}", "%{dummy_string}")
+if (!(result_octets == 0x74e6f7298a9c2d168935f58c001bad88)) {
test_fail
}
string test_string
octets result_octets
-&test_string := "hello"
+test_string := "hello"
#
# MD5 HMAC with missing key should fail
#
-&result_octets := %hmacmd5(%{test_string}, )
-if &result_octets {
+result_octets := %hmacmd5(%{test_string}, )
+if result_octets {
test_fail
}
success
test
-if !(&Module-Failure-Message[4] == 'test: RERROR error message') {
+if !(Module-Failure-Message[4] == 'test: RERROR error message') {
test_fail
}
-if !(&Module-Failure-Message[3] == 'test: RDEBUG error message') {
+if !(Module-Failure-Message[3] == 'test: RDEBUG error message') {
test_fail
}
-if !(&Module-Failure-Message[2] == 'test: RDEBUG2 error message') {
+if !(Module-Failure-Message[2] == 'test: RDEBUG2 error message') {
test_fail
}
-if !(&Module-Failure-Message[1] == 'test: RDEBUG3 error message') {
+if !(Module-Failure-Message[1] == 'test: RDEBUG3 error message') {
test_fail
}
-if !(&Module-Failure-Message[0] == 'test: RDEBUG4 error message') {
+if !(Module-Failure-Message[0] == 'test: RDEBUG4 error message') {
test_fail
}
#
# over-write the existing User-Name
#
-&User-Name := 'EXAMPLE\bob'
+User-Name := 'EXAMPLE\bob'
# MS CHAPv1
-&request += {
- &Vendor-Specific.Microsoft.CHAP-Challenge = 0xe96e4fff2955c4f1
- &Vendor-Specific.Microsoft.CHAP-Response = 0x00010000000000000000000000000000000000000000000000008860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f
+request += {
+ Vendor-Specific.Microsoft.CHAP-Challenge = 0xe96e4fff2955c4f1
+ Vendor-Specific.Microsoft.CHAP-Response = 0x00010000000000000000000000000000000000000000000000008860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f
}
-&result_octets := %mschap(Challenge)
-if !(&result_octets == 0xe96e4fff2955c4f1) {
+result_octets := %mschap(Challenge)
+if !(result_octets == 0xe96e4fff2955c4f1) {
test_fail
}
-&result_octets := %mschap(NT-Response)
-if !(&result_octets == 0x8860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f) {
+result_octets := %mschap(NT-Response)
+if !(result_octets == 0x8860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f) {
test_fail
}
-&result_string := %mschap(NT-Domain)
-if !(&result_string == 'EXAMPLE') {
+result_string := %mschap(NT-Domain)
+if !(result_string == 'EXAMPLE') {
test_fail
}
-&result_string := %mschap(User-Name)
-if !(&result_string == 'bob') {
+result_string := %mschap(User-Name)
+if !(result_string == 'bob') {
test_fail
}
-&request.Vendor-Specific.Microsoft.CHAP-Response := 0x00006937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db158860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f
+request.Vendor-Specific.Microsoft.CHAP-Response := 0x00006937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db158860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f
-&result_octets := %mschap(LM-Response)
+result_octets := %mschap(LM-Response)
-if !(&result_octets == 0x6937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db15) {
+if !(result_octets == 0x6937d7935bb28a4c1dafe6a193bdea7a853a74d8bcf6db15) {
test_fail
}
# Hashing
-&result_octets := %mschap(NT-Hash, 'testing_123')
-if !(&result_octets == 0xfa782604f85eb3564f555648341b53e4) {
+result_octets := %mschap(NT-Hash, 'testing_123')
+if !(result_octets == 0xfa782604f85eb3564f555648341b53e4) {
test_fail
}
-&result_octets := %mschap(LM-Hash, 'testing_123')
-if !(&result_octets == 0x2d5545077d7b7d2ae4343f96ab15c596) {
+result_octets := %mschap(LM-Hash, 'testing_123')
+if !(result_octets == 0x2d5545077d7b7d2ae4343f96ab15c596) {
test_fail
}
# MS CHAPv2
-&request -= &Vendor-Specific.Microsoft.CHAP-Response[*]
+request -= Vendor-Specific.Microsoft.CHAP-Response[*]
-&Vendor-Specific.Microsoft.CHAP-Challenge := 0x04408dc2a98dae1ce351dfc53f57d08e
-&Vendor-Specific.Microsoft.CHAP2-Response := 0x00010e93cfbfcef8d5b6af42d2b2ca5b43180000000000000000bc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b200
+Vendor-Specific.Microsoft.CHAP-Challenge := 0x04408dc2a98dae1ce351dfc53f57d08e
+Vendor-Specific.Microsoft.CHAP2-Response := 0x00010e93cfbfcef8d5b6af42d2b2ca5b43180000000000000000bc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b200
-&result_octets := %mschap(Challenge)
-if !(&result_octets == 0xad18b6b8e1478b4c) {
+result_octets := %mschap(Challenge)
+if !(result_octets == 0xad18b6b8e1478b4c) {
test_fail
}
-&result_octets := %mschap(NT-Response)
-if !(&result_octets == 0xbc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b2) {
+result_octets := %mschap(NT-Response)
+if !(result_octets == 0xbc068d1e8c54de5e9db78e6736d686eb88a999dd7fa239b2) {
test_fail
}
# Invalid
-&Vendor-Specific.Microsoft.CHAP-Challenge := 0xf0eac4151d5346662ba8c5e428
-&result_string := %mschap(Challenge)
+Vendor-Specific.Microsoft.CHAP-Challenge := 0xf0eac4151d5346662ba8c5e428
+result_string := %mschap(Challenge)
-if (&result_string) {
+if (result_string) {
test_fail
}
-if (!(&Module-Failure-Message == "Invalid MS-CHAP challenge length")) {
+if (!(Module-Failure-Message == "Invalid MS-CHAP challenge length")) {
test_fail
}
#
# This is the default for the tests
#
-if !(&Net.Src.IP == 127.0.0.1) {
+if !(Net.Src.IP == 127.0.0.1) {
test_fail
}
success
# different numbers of days involved. Check hour / day / week
#
-&result_integer := "%{%nexttime(2h) - %nexttime(1h)}"
+result_integer := "%{%nexttime(2h) - %nexttime(1h)}"
# We have a fudge factor of 1 second either way
-if ((&result_integer < 3599) || (&result_integer > 3601)) {
+if ((result_integer < 3599) || (result_integer > 3601)) {
test_fail
}
#
# Day
#
-&result_integer := "%{%nexttime(3d) - %nexttime(1d)}"
-if ((&result_integer < 172799) || (&result_integer > 172801)) {
+result_integer := "%{%nexttime(3d) - %nexttime(1d)}"
+if ((result_integer < 172799) || (result_integer > 172801)) {
test_fail
}
#
# Week
#
-&result_integer := "%{%nexttime(4w) - %nexttime(2w)}"
-if ((&result_integer < 1209599) || (&result_integer > 1209601)) {
+result_integer := "%{%nexttime(4w) - %nexttime(2w)}"
+if ((result_integer < 1209599) || (result_integer > 1209601)) {
test_fail
}
#
# This doesn't exist, so the condition shouldn't match.
#
-if (&dummy_string == "foo") {
+if (dummy_string == "foo") {
test_fail
}
else {
#
# Since the middle part doesn't match, "NOT" the middle part SHOULD match.
#
-if (!(&dummy_string == "foo")) {
+if (!(dummy_string == "foo")) {
ok
}
else {
-&control.Auth-Type := ::Accept
-&reply.Reply-Message := 'pass'
+control.Auth-Type := ::Accept
+reply.Reply-Message := 'pass'
# Section should exit after this statement
#
octets result_octets
-&request += {
- &Framed-IP-Address = 127.0.0.1
- &NAS-Port = 2112
- &NAS-IP-Address = 127.0.0.2
+request += {
+ Framed-IP-Address = 127.0.0.1
+ NAS-Port = 2112
+ NAS-IP-Address = 127.0.0.2
}
-&result_octets := (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 (!(&result_octets == 0x7f000001000008407f000002)) {
+if (!(result_octets == 0x7f000001000008407f000002)) {
test_fail
}
#
# With octet addition, we don't need %pack() any more!
#
-&result_octets := (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 (!(&result_octets == 0x7f000001000008407f000002)) {
+if (!(result_octets == 0x7f000001000008407f000002)) {
test_fail
}
#
string test_string
-&test_string = "test"
+test_string = "test"
#
# rpad tests
#
string result_string
-&request -= &Packet-Type[*]
+request -= Packet-Type[*]
-&Tmp-Group-0 += {
- &Filter-Id = "This is a string"
- &Filter-Id = "This is another one"
- &Class = 0x000504030201
- &NAS-Port = 7331
+Tmp-Group-0 += {
+ Filter-Id = "This is a string"
+ Filter-Id = "This is another one"
+ Class = 0x000504030201
+ NAS-Port = 7331
}
#
# @todo - this doesn't work. tmpl_afrom_attr_substr() doesn't check
# the tail da, or the parent of the tail.
#
-#&pairs := %{(string) %{Tmp-Group-0.[*]}}
+#pairs := %{(string) %{Tmp-Group-0.[*]}}
#
# However, this does "work". It returns a concatenated string
# of the _values_ of the attributes, which doesn't include th
# attribute names.
#
-#&pairs := %cast('string', %{Tmp-Group-0.[*]})
+#pairs := %cast('string', %{Tmp-Group-0.[*]})
-&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') {
+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
}
-&result_string := "%pairs(Tmp-Group-0.Filter-Id)"
-if !(&result_string == 'Filter-Id = "This is a string"') {
+result_string := "%pairs(Tmp-Group-0.Filter-Id)"
+if !(result_string == 'Filter-Id = "This is a string"') {
test_fail
}
-&result_string := "%concat(%pairs(Tmp-Group-0.Filter-Id[*]), ', ')"
-if !(&result_string == 'Filter-Id = "This is a string", Filter-Id = "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
#
-&result_string := "%concat(%pairs(control.[*]), ', ')"
-if !(&result_string == 'Password = { Cleartext = "hello" }') {
+result_string := "%concat(%pairs(control.[*]), ', ')"
+if !(result_string == 'Password = { Cleartext = "hello" }') {
test_fail
}
-&result_string := "%pairs(control.User-Name)"
-if (!(&result_string == '')) {
+result_string := "%pairs(control.User-Name)"
+if (!(result_string == '')) {
test_fail
}
-&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 }') {
+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.Filter-Id) {
+request -= Tmp-Group-0[*]
+if (request.Tmp-Group-0.Filter-Id) {
test_fail
}
#
# Parse pairs from a string!
#
-&request += "%{result_string}"
-if !(&request.Tmp-Group-0.Filter-Id == 'This is a string') {
+request += "%{result_string}"
+if !(request.Tmp-Group-0.Filter-Id == 'This is a string') {
test_fail
}
string result_string
octets result_octets
-&control := {}
-&salt := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
+control := {}
+salt := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
#
# Unencoded Password.Cleartext in password with header
#
-&control := {
- &Password.With-Header = &User-Password
+control := {
+ Password.With-Header = User-Password
}
pap.authorize
#
# Base64 encoded Password.Cleartext in password with header
#
-&result_string := "{clear}%{User-Password}"
-&control := {
- &Password.With-Header = %base64.encode(%{result_string})
+result_string := "{clear}%{User-Password}"
+control := {
+ Password.With-Header = %base64.encode(%{result_string})
}
pap.authorize
#
# Hex encoded SSHA password
#
-&control := {
- &Password.With-Header = "{ssha}%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
+control := {
+ Password.With-Header = "{ssha}%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
}
pap.authorize
#
# Base64 encoded SSHA password
#
-&result_string := "%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
+result_string := "%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&result_octets := "%bin(%{result_string})"
+result_octets := "%bin(%{result_string})"
# To Base64
-&result_string := "%base64.encode(%{result_octets})"
-&control.Password.With-Header := "{ssha}%{result_string}"
+result_string := "%base64.encode(%{result_octets})"
+control.Password.With-Header := "{ssha}%{result_string}"
pap.authorize
pap.authenticate {
#
# Base64 of Base64 encoded SSHA password
#
-&result_string := "%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
+result_string := "%hex(%sha1(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&result_octets := "%bin(%{result_string})"
+result_octets := "%bin(%{result_string})"
# To Base64
-&result_string := "{ssha}%base64.encode(%{result_octets})"
-&control.Password.With-Header := "%base64.encode(%{result_string})"
+result_string := "{ssha}%base64.encode(%{result_octets})"
+control.Password.With-Header := "%base64.encode(%{result_string})"
pap.authorize
pap.authenticate {
}
-&control := {
- &Auth-Type = ::Accept
+control := {
+ Auth-Type = ::Accept
}
success
# Skip if the server wasn't built with openssl
#
if (!('${feature.tls}' == 'yes')) {
- &reply.Packet-Type := Access-Accept
+ reply.Packet-Type := Access-Accept
handled
}
-&control := {}
-&salt := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
+control := {}
+salt := "5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK" # 60 byte salt
#
# Hex encoded SSHA2-512 password
#
-&control += {
- &Password.With-Header = "{ssha512}%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
+control += {
+ Password.With-Header = "{ssha512}%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
}
pap.authorize
test_fail
}
-&control := {}
+control := {}
#
# Base64 encoded SSHA2-512 password
#
-&result_string := "%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
+result_string := "%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&result_octets := "%bin(%{result_string})"
+result_octets := "%bin(%{result_string})"
# To Base64
-&result_string := "%base64.encode(%{result_octets})"
+result_string := "%base64.encode(%{result_octets})"
-&control += {
- &Password.With-Header = "{ssha512}%{result_string}"
+control += {
+ Password.With-Header = "{ssha512}%{result_string}"
}
pap.authorize
test_fail
}
-&control := {}
+control := {}
#
# Base64 of Base64 encoded SSHA2-512 password
#
-&result_string := "%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
+result_string := "%hex(%sha2_512(%{User-Password}%{salt}))%hex(%{salt})"
# To Binary
-&result_octets := "%bin(%{result_string})"
+result_octets := "%bin(%{result_string})"
# To Base64
-&result_string := "{ssha512}%base64.encode(%{result_octets})"
+result_string := "{ssha512}%base64.encode(%{result_octets})"
-&control += {
- &Password.With-Header = "%base64.encode(%{result_string})"
+control += {
+ Password.With-Header = "%base64.encode(%{result_string})"
}
pap.authorize
test_fail
}
-&control := {}
+control := {}
#
# Base64 of SHA2-384 password (in SHA2-Password)
#
-&control.Password.SHA2 := %hex(%sha2_384(%{User-Password}))
+control.Password.SHA2 := %hex(%sha2_384(%{User-Password}))
pap.authorize
pap.authenticate {
test_fail
}
-&control := {
- &Auth-Type = ::Accept
+control := {
+ Auth-Type = ::Accept
}
#
# Base64 of SHA2-256 password (in SHA2-256-Password)
#
-&control.Password.SHA2-256 := "%hex(%sha2_256(%{User-Password}))"
+control.Password.SHA2-256 := "%hex(%sha2_256(%{User-Password}))"
pap.authorize
pap.authenticate {
test_fail
}
-&control := {}
+control := {}
#
# Base64 of SHA2-224 password (in SHA2-224-Password - No hex armour)
#
-&control.Password.SHA2-224 := "%sha2_224(%{User-Password})"
+control.Password.SHA2-224 := "%sha2_224(%{User-Password})"
pap.authorize
pap.authenticate {
test_fail
}
-&control := {
- &Auth-Type = ::Accept
+control := {
+ Auth-Type = ::Accept
}
success
parallel {
group {
- &parent.control += {
- &NAS-Port = 1
+ parent.control += {
+ NAS-Port = 1
}
}
group {
- &parent.control += {
- &NAS-Port = 3
+ parent.control += {
+ NAS-Port = 3
}
}
group {
- &parent.control += {
- &NAS-Port = 5
+ parent.control += {
+ NAS-Port = 5
}
}
group {
- &parent.control += {
- &NAS-Port = 7
+ parent.control += {
+ NAS-Port = 7
}
}
}
parallel {
fail
group { # This should *NOT* be dispatched
- &Filter-Id := 'foo'
+ Filter-Id := 'foo'
}
}
actions {
if (!fail) {
test_fail
}
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
fail = 10 # Higher priority than ok and no longer action return
}
group { # This should now be dispatched
- &parent.request.Filter-Id := 'foo'
+ parent.request.Filter-Id := 'foo'
}
}
actions {
if (!fail) {
test_fail
}
-if (!(&Filter-Id == 'foo')) {
+if (!(Filter-Id == 'foo')) {
test_fail
}
parallel {
reschedule
group {
- &parent.request.Filter-Id := 'foo'
+ parent.request.Filter-Id := 'foo'
}
}
-if (!(&Filter-Id == 'foo')) {
+if (!(Filter-Id == 'foo')) {
test_fail
}
string result_string
uint32 result_integer
-&result_integer := %rand('123')
-if (!&result_integer) {
+result_integer := %rand('123')
+if (!result_integer) {
test_fail
}
#
# Make sure random number is within limit
#
-if (&result_integer < 0 || &result_integer > 123) {
+if (result_integer < 0 || result_integer > 123) {
test_fail
}
#
# Empty output on empty input
#
-&result_string := "%randstr(%{result_string})"
-if !(&result_string == "") {
+result_string := "%randstr(%{result_string})"
+if !(result_string == "") {
test_fail
}
#
# Check length of output
#
-&result_string := "%randstr(nnn)"
+result_string := "%randstr(nnn)"
if (!(%length(%{result_string}) == 3)) {
test_fail
}
-&result_string := "%randstr(24a)"
+result_string := "%randstr(24a)"
if (!(%length(%{result_string}) == 24)) {
test_fail
}
#
# Check maximum repetition
#
-&result_string := "%randstr(1030aa)"
+result_string := "%randstr(1030aa)"
if (!(%length(%{result_string}) == 1025)) {
test_fail
}
#
# Check invalid character class
#
-&result_string := "%randstr(G)"
+result_string := "%randstr(G)"
-if !(&result_string == "") {
+if !(result_string == "") {
test_fail
}
#
# Check repetition of binary output
#
-&result_string := "%randstr(10b)"
+result_string := "%randstr(10b)"
if (!(%length(%{result_string}) == 10)) {
test_fail
}
#
uint32 count
-&count := 0
-&request += {
- &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
+count := 0
+request += {
+ 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 {
uint32 foo
group {
- &foo := 1
+ foo := 1
fail
}
group {
- if !(&foo == 1) {
+ if !(foo == 1) {
test_fail
}
success
}
}
-if (!&reply.Result-Status) {
+if (!reply.Result-Status) {
test_fail
}
#
# Loop 0..9
#
-foreach &NAS-Port {
+foreach NAS-Port {
redundant {
group {
# fail on even numbered values, succeed on odd numbered ones
fail
}
else {
- &count += 1
- &request += {
- &Reply-Message = "Succeed odd %{Foreach-Variable-0} %{count}"
+ count += 1
+ request += {
+ Reply-Message = "Succeed odd %{Foreach-Variable-0} %{count}"
}
ok
}
fail
}
else {
- &count += 1
- &request += {
- &Reply-Message = "Succeed even %{Foreach-Variable-0} %{count}"
+ count += 1
+ request += {
+ Reply-Message = "Succeed even %{Foreach-Variable-0} %{count}"
}
ok
}
}
}
-if (!(&count == %{NAS-Port[#]})) {
+if (!(count == %{NAS-Port[#]})) {
test_fail
}
#
uint32 count
-&count := 0;
-&request += {
- &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
+count := 0;
+request += {
+ 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 &NAS-Port {
+foreach NAS-Port {
redundant-load-balance {
group {
# fail on even numbered values, succeed on odd numbered ones
fail
}
else {
- &count += 1
- &request += {
- &Reply-Message = "Succeed odd %{Foreach-Variable-0} %{count}"
+ count += 1
+ request += {
+ Reply-Message = "Succeed odd %{Foreach-Variable-0} %{count}"
}
ok
}
fail
}
else {
- &count += 1
- &request += {
- &Reply-Message = "Succeed even %{Foreach-Variable-0} %{count}"
+ count += 1
+ request += {
+ Reply-Message = "Succeed even %{Foreach-Variable-0} %{count}"
}
ok
}
}
}
-if (!(&count == %{NAS-Port[#]})) {
+if (!(count == %{NAS-Port[#]})) {
test_fail
}
redundant {
- map test-fail &Filter-Id {
- &NAS-Port := '$[3][2]'
+ map test-fail Filter-Id {
+ NAS-Port := '$[3][2]'
}
noop
}
-if (noop || (&NAS-Port == 4294967295)) {
+if (noop || (NAS-Port == 4294967295)) {
success
} else {
fail
uint32 count3
uint32 count4
-&count1 = 0
-&count2 = 0
-&count3 = 0
-&count4 = 0
+count1 = 0
+count2 = 0
+count3 = 0
+count4 = 0
redundant {
redundant-load-balance {
group {
- &count1 += 1
+ count1 += 1
fail
}
group {
- &count2 += 1
+ count2 += 1
fail
}
group {
- &count3 += 1
+ count3 += 1
fail
}
group {
- &count4 += 1
+ count4 += 1
fail
}
}
return
}
-if (!(&count1 == 1)) {
+if (!(count1 == 1)) {
test_fail
}
-if (!(&count2 == 1)) {
+if (!(count2 == 1)) {
test_fail
return
}
-if (!(&count3 == 1)) {
+if (!(count3 == 1)) {
test_fail
return
}
-if (!(&count4 == 1)) {
+if (!(count4 == 1)) {
test_fail
return
}
# Strings which are expanded in a regex have regex special
# characters escaped. Because the input strings are unsafe.
#
-&test_string1 := "%taint(example.com)"
-&test_string2 := "%taint(exampleXcom)"
+test_string1 := "%taint(example.com)"
+test_string2 := "%taint(exampleXcom)"
if ("exampleXcom" =~ /%{test_string1}/) {
test_fail
}
-if (&test_string2 =~ /%{test_string1}/) {
+if (test_string2 =~ /%{test_string1}/) {
test_fail
}
# Strings which are expanded in a regex have regex special
# characters escaped. Because the input strings are unsafe.
#
-&test_string1 = "example.com"
-&test_string2 = "^foo$bar"
+test_string1 = "example.com"
+test_string2 = "^foo$bar"
-if !(&test_string1 =~ /example\.com$/) {
+if !(test_string1 =~ /example\.com$/) {
test_fail
}
-elsif !(&test_string2 =~ /\^foo\$bar/) {
+elsif !(test_string2 =~ /\^foo\$bar/) {
test_fail
}
# PRE: if
uint32 count
-&count := 0
+count := 0
group {
- &count += 1
+ count += 1
noop
actions {
}
}
-if (!(&count == 3)) {
+if (!(count == 3)) {
test_fail
}
#
# PRE: if
#
-if (&User-Name == "bob") {
+if (User-Name == "bob") {
success
#
# will prevent the "pap" module from being run
# in the "authorize" section.
#
- &control.Auth-Type := ::PAP
+ control.Auth-Type := ::PAP
#
# Stop processing "authorize", and go to the next section.
#
# PRE: if return foreach
#
-&control += {
- &NAS-Port = 0
- &NAS-Port = 1
- &NAS-Port = 2
- &NAS-Port = 3
+control += {
+ NAS-Port = 0
+ NAS-Port = 1
+ NAS-Port = 2
+ NAS-Port = 3
}
-foreach &control.NAS-Port {
+foreach control.NAS-Port {
policy_return
# Should continue executing
break
}
- &control -= {
- &NAS-Port == "%{Foreach-Variable-0}"
+ control -= {
+ NAS-Port == "%{Foreach-Variable-0}"
}
}
# Everything should have been removed except
-# the last incidence of &NAS-Port
-if (!&control.NAS-Port) {
+# the last incidence of NAS-Port
+if (!control.NAS-Port) {
test_fail
}
-if (!(&control.NAS-Port[0] == 2)) {
+if (!(control.NAS-Port[0] == 2)) {
test_fail
}
#
# PRE: return
#
-&control.Auth-Type := 'Accept'
+control.Auth-Type := 'Accept'
group {
# Section should exit after this statement
}
# This entry should never be reached
- &reply.Reply-Message := 'fail'
+ reply.Reply-Message := 'fail'
}
# We should continue processing after the previous group.
-&reply.Reply-Message := 'pass'
+reply.Reply-Message := 'pass'
#
# PRE: if return
#
-if (&User-Name == "bob") {
+if (User-Name == "bob") {
ok
#
# will prevent the "pap" module from being run
# in the "authorize" section.
#
- &control.Auth-Type := ::PAP
+ control.Auth-Type := ::PAP
#
# Stop processing "authorize", and go to the next section.
#
# PRE: if
#
-if (&User-Name == 'bob') {
+if (User-Name == 'bob') {
accept
success
return
}
# Should not execute this condition
-if (&User-Name == 'bob') {
+if (User-Name == 'bob') {
reject
}
}
# Should not execute this condition
-if (&User-Name == 'bob') {
+if (User-Name == 'bob') {
reject
}
#
# PRE: if return foreach
#
-&control += {
- &NAS-Port = 0
- &NAS-Port = 1
- &NAS-Port = 2
- &NAS-Port = 3
+control += {
+ NAS-Port = 0
+ NAS-Port = 1
+ NAS-Port = 2
+ NAS-Port = 3
}
group {
- foreach &control.NAS-Port {
+ foreach control.NAS-Port {
if ("%{Foreach-Variable-0}" == '2') {
accept
success
if ('true' == 'true') {
accept
success
- if(&User-Name == 'bob') {
+ if(User-Name == 'bob') {
%debug(%debug(0)) # Noop
return
}
octets result_octets
-&test_string := "This is a string\n"
-&test_hmac_key := "what do ya want for nothing?"
-&test_hmac_data := "Jefe"
+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.
#
-&result_octets := %sha1("This is a string\n")
-if (!(&result_octets == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
+result_octets := %sha1("This is a string\n")
+if (!(result_octets == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
test_fail
}
-&result_octets := %sha1("%{test_string}")
-if (!(&result_octets == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
+result_octets := %sha1("%{test_string}")
+if (!(result_octets == 0xcc7edf1ccc4bdf1e0ec8f72b95388b65218ecf0c)) {
test_fail
}
#
# SHA1 of empty string
#
-&result_octets := %sha1("%{dummy_string}")
-if (!(&result_octets == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709)) {
+result_octets := %sha1("%{dummy_string}")
+if (!(result_octets == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709)) {
test_fail
}
#
# SHA1 HMAC with attribute references
#
-&result_octets := %hmacsha1("%{test_hmac_key}", "%{test_hmac_data}")
-if (!(&result_octets == 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79)) {
+result_octets := %hmacsha1("%{test_hmac_key}", "%{test_hmac_data}")
+if (!(result_octets == 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79)) {
test_fail
}
#
# SHA1 HMAC with empty key and data
#
-&dummy_string := ''
-&result_octets := %hmacsha1("%{dummy_string}", "%{dummy_string}")
-if (!(&result_octets == 0xfbdb1d1b18aa6c08324b7d64b71fb76370690e1d)) {
+dummy_string := ''
+result_octets := %hmacsha1("%{dummy_string}", "%{dummy_string}")
+if (!(result_octets == 0xfbdb1d1b18aa6c08324b7d64b71fb76370690e1d)) {
test_fail
}
string test_string
octets result_octets
-&test_string := "hello"
+test_string := "hello"
#
# SHA1 HMAC with missing key should fail
#
-&result_octets := %hmacsha1(%{test_string}, ) # ERROR
-if &result_octets {
+result_octets := %hmacsha1(%{test_string}, ) # ERROR
+if result_octets {
test_fail
}
success
octets dummy_octets
octets result_octets
-&test_string := "This is a string\n"
-&test_octets := 0x000504030201
+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.
#
-&result_octets := %sha2_256("This is a string\n")
-if (!(&result_octets == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
+result_octets := %sha2_256("This is a string\n")
+if (!(result_octets == 0xb3716a1ab53042bb392034f29071e13b0c38aa19b4edd75d9a76022f91189124)) {
test_fail
}
-&result_octets := %sha2_256(%{test_string})
-if (!(&result_octets == 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
#
-&result_octets := %sha2_256(%{test_octets})
-if (!(&result_octets == 0xf307e202b881fded70e58017aa0c4d7b29c76ab25d02bf078301a5f6635187eb)) {
+result_octets := %sha2_256(%{test_octets})
+if (!(result_octets == 0xf307e202b881fded70e58017aa0c4d7b29c76ab25d02bf078301a5f6635187eb)) {
test_fail
}
#
# SHA256 of empty string
#
-&result_octets := %sha2_256(%{dummy_octets})
-if (!(&result_octets == 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.
#
-&result_octets := %sha2_512("This is a string\n")
-if (!(&result_octets == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
+result_octets := %sha2_512("This is a string\n")
+if (!(result_octets == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
test_fail
}
-&result_octets := %sha2_512(%{test_string})
-if (!(&result_octets == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
+result_octets := %sha2_512(%{test_string})
+if (!(result_octets == 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f)) {
test_fail
}
-&result_octets := %sha2_512(%{test_octets})
-if (!(&result_octets == 0xde80271eb5e03a1c24dd0cd823a22305a743ee3a54f1de5bf97adbf56984561154bfb6928b1da4ccc3f5dde9f4032ad461937b60b9ace4ad3898cf45c90596d7)) {
+result_octets := %sha2_512(%{test_octets})
+if (!(result_octets == 0xde80271eb5e03a1c24dd0cd823a22305a743ee3a54f1de5bf97adbf56984561154bfb6928b1da4ccc3f5dde9f4032ad461937b60b9ace4ad3898cf45c90596d7)) {
test_fail
}
-&NAS-Port := -1000 # ERROR
+NAS-Port := -1000 # ERROR
test_fail
+++ /dev/null
-#
-# PRE: subrequest
-#
-
-# Cancel in subrequest
-subrequest Access-Request {
- %cancel()
- test_fail
-}
-
-# Cancel in nested subrequest
-subrequest Access-Request {
- subrequest Access-Request {
- %cancel()
- test_fail
- }
-}
-
-# Cancel parent with active subrequest, will run on next timer service
-%cancel(100ms)
-subrequest Access-Request {
- %delay_10s(1s)
-}
-
-test_fail
-
+++ /dev/null
-#
-# Input packet
-#
-Packet-Type = Access-Request
-
-#
-# Expected answer
-#
-Packet-Type == 0
subrequest ::Access-Request {
- &parent.control.User-Name := 'bob'
+ parent.control.User-Name := 'bob'
success
}
-if (!&control.User-Name) {
+if (!control.User-Name) {
test_fail
}
-if (!(&control.User-Name == 'bob')) {
+if (!(control.User-Name == 'bob')) {
test_fail
}
#
# PRE: subrequest
#
-&control.Filter-Id := "Access-Request"
+control.Filter-Id := "Access-Request"
#
# Subrequest with an attribute reference
#
-subrequest &control.Filter-Id {
- &parent.control.User-Name := 'bob'
+subrequest control.Filter-Id {
+ parent.control.User-Name := 'bob'
success
}
-if (!&control.User-Name) {
+if (!control.User-Name) {
test_fail
}
-if (!(&control.User-Name == 'bob')) {
+if (!(control.User-Name == 'bob')) {
test_fail
}
# Cancel in subrequest
subrequest ::Access-Request {
- &parent.foo := 'testing'
+ parent.foo := 'testing'
# Immediately cancel the subrequest
%cancel(0)
- &parent.bar := 'should not see me'
+ parent.bar := 'should not see me'
# We should've been cancelled here
test_fail
}
-if (!(&foo == 'testing')) {
+if (!(foo == 'testing')) {
test_fail
}
-if (&bar == 'should not see me') {
+if (bar == 'should not see me') {
test_fail
}
success
#
# PRE: subrequest
#
-&Filter-Id := 'testing'
+Filter-Id := 'testing'
# Cancel in subrequest
subrequest ::Access-Request {
detach
# Smoke test, check for crashes
- if (&parent.Filter-Id == 'testing') {
+ if (parent.Filter-Id == 'testing') {
test_fail
}
- &parent.Reply-Message = '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 (&Reply-Message && (&Reply-Message == 'testing')) {
+if (Reply-Message && (Reply-Message == 'testing')) {
test_fail
}
# PRE: subrequest
#
subrequest ::Access-Request {
- &User-Name := &parent.request.User-Name
+ User-Name := parent.request.User-Name
- if (!&User-Name) {
+ if (!User-Name) {
test_fail
}
- if (!(&User-Name == 'bob')) {
+ if (!(User-Name == 'bob')) {
test_fail
}
- &parent.control.User-Name := 'bob'
+ parent.control.User-Name := 'bob'
success
}
#
# Prefix/attribute parsing disambiguation
#
- &outer.request.Outer-Realm-Name := 'testing123'
+ outer.request.Outer-Realm-Name := 'testing123'
- &User-Name := "obo"
+ User-Name := "obo"
subrequest ::Access-Request {
- &User-Name := "jim"
+ User-Name := "jim"
subrequest ::Access-Request {
- &User-Name := "joe"
+ User-Name := "joe"
- &outer.request += {
- &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}"
+ outer.request += {
+ Filter-Id = current.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 = current.outer.User-Name
+ Filter-Id = parent.current.outer.User-Name
+ Filter-Id = "%{parent.parent.parent.parent.User-Name}"
+ Filter-Id = "%{outer.parent.User-Name}"
}
}
}
}
-if !(&Outer-Realm-Name == 'testing123') {
+if !(Outer-Realm-Name == 'testing123') {
test_fail
}
-if !(&Filter-Id[0] == 'joe') {
+if !(Filter-Id[0] == 'joe') {
test_fail
}
-if !(&Filter-Id[1] == 'jim') {
+if !(Filter-Id[1] == 'jim') {
test_fail
}
-if !(&Filter-Id[2] == 'obo') {
+if !(Filter-Id[2] == 'obo') {
test_fail
}
-if !(&Filter-Id[3] == 'bob') {
+if !(Filter-Id[3] == 'bob') {
test_fail
}
-if !(&Filter-Id[4] == 'bob') {
+if !(Filter-Id[4] == 'bob') {
test_fail
}
-if !(&Filter-Id[5] == 'bob') {
+if !(Filter-Id[5] == 'bob') {
test_fail
}
-if !(&Filter-Id[6] == 'bob') {
+if !(Filter-Id[6] == 'bob') {
test_fail
}
-if !(&Filter-Id[7] == "") {
+if !(Filter-Id[7] == "") {
test_fail
}
-if !(&Filter-Id[8] == "") {
+if !(Filter-Id[8] == "") {
test_fail
}
subrequest ::Access-Request {
- &parent.request.Filter-Id := "testing1234"
+ parent.request.Filter-Id := "testing1234"
return
#
# Should be ignored
#
- &parent.request.Reply-Message := "testing1234"
+ parent.request.Reply-Message := "testing1234"
}
-if (&Reply-Message) {
+if (Reply-Message) {
test_fail
}
-if (!(&Filter-Id == "testing1234")) {
+if (!(Filter-Id == "testing1234")) {
test_fail
}
#
# PRE: subrequest
#
-subrequest ::Access-Request &request &reply.Tmp-Group-0 {
- if (!&User-Name) {
+subrequest ::Access-Request request reply.Tmp-Group-0 {
+ if (!User-Name) {
test_fail
}
- if (!(&User-Name == 'bob')) {
+ if (!(User-Name == 'bob')) {
test_fail
}
- &reply.Filter-Id := 'hello from subrequest'
+ reply.Filter-Id := 'hello from subrequest'
}
-if (!&reply.Tmp-Group-0) {
+if (!reply.Tmp-Group-0) {
test_fail
}
-if (!&reply.Tmp-Group-0.Filter-Id) {
+if (!reply.Tmp-Group-0.Filter-Id) {
test_fail
}
-if !(&reply.Tmp-Group-0.Filter-Id == 'hello from subrequest') {
+if !(reply.Tmp-Group-0.Filter-Id == 'hello from subrequest') {
test_fail
}
#
# PRE: subrequest
#
-subrequest ::Access-Request &request &reply.Tmp-Group-0 {
- subrequest ::Access-Request &request &reply.Tmp-Group-0 {
- if (!&User-Name) {
+subrequest ::Access-Request request reply.Tmp-Group-0 {
+ subrequest ::Access-Request request reply.Tmp-Group-0 {
+ if (!User-Name) {
test_fail
}
- if (!(&User-Name == 'bob')) {
+ if (!(User-Name == 'bob')) {
test_fail
}
- &reply.Filter-Id := 'hello from subrequest'
+ reply.Filter-Id := 'hello from subrequest'
}
}
-if (!&reply.Tmp-Group-0.Tmp-Group-0) {
+if (!reply.Tmp-Group-0.Tmp-Group-0) {
test_fail
}
-if (!&reply.Tmp-Group-0.Tmp-Group-0.Filter-Id) {
+if (!reply.Tmp-Group-0.Tmp-Group-0.Filter-Id) {
test_fail
}
-if !(&reply.Tmp-Group-0.Tmp-Group-0.Filter-Id == 'hello from subrequest') {
+if !(reply.Tmp-Group-0.Tmp-Group-0.Filter-Id == 'hello from subrequest') {
test_fail
}
octets test_octets
uint32 test_int
-&test_string = "hello world"
-&test_octets = 0x01234567
-&test_int = 123456
+test_string = "hello world"
+test_octets = 0x01234567
+test_int = 123456
if !(%substr(%{test_string}, 1, 3) == 'ell') {
test_fail
-switch &User-Name {
+switch User-Name {
case "bob" {
success
}
case "doug" {
- &Filter-Id := "doug"
+ Filter-Id := "doug"
test_fail
}
default {
- &Filter-Id := "default"
+ Filter-Id := "default"
test_fail
}
}
}
case 'doug' {
- &Filter-Id := "doug"
+ Filter-Id := "doug"
test_fail
}
default {
- &Filter-Id := "default"
+ Filter-Id := "default"
test_fail
}
}
-switch &User-Name {
+switch User-Name {
case "%{Filter-Id}" { # ERROR
success
}
case "doug" {
- &Filter-Id := "doug"
+ Filter-Id := "doug"
}
default {
- &Filter-Id := "default"
+ Filter-Id := "default"
}
}
# PRE: switch
#
-switch &User-Name {
+switch User-Name {
case "harry" {
- &Filter-Id := "harry"
+ Filter-Id := "harry"
}
case "doug" {
- &Filter-Id := "doug"
+ Filter-Id := "doug"
}
case {
string test_string
-&test_string := 'foo'
+test_string := 'foo'
switch "%tolower(%{test_string})" {
case 'foo' {
-&request.REST-HTTP-Status-Code := 200
+request.REST-HTTP-Status-Code := 200
-switch &request.REST-HTTP-Status-Code {
+switch request.REST-HTTP-Status-Code {
case 200 {
success
}
# User-Name is "bob", and a switch statement
# with no "default" should not crash the server.
#
-switch &User-Name {
+switch User-Name {
case "doug" {
- &Filter-Id := "doug"
+ Filter-Id := "doug"
}
}
-if (&reply.Filter-Id) {
+if (reply.Filter-Id) {
test_fail
}
#
# PRE: switch
#
-switch &Service-Type {
+switch Service-Type {
case Login-User {
test_fail
}
#
# Virtual attribute references get mashed to xlats
#
-switch &Packet-Type {
+switch Packet-Type {
case Access-Request {
success
}
#
# PRE: switch
#
-switch &User-Name {
+switch User-Name {
case "%no-such-module(bob)" { # ERROR
test_fail
}
#
redundant {
timeout 0.01s {
- &a := %delay_10s(0.1)
+ a := %delay_10s(0.1)
test_fail
}
redundant {
timeout "0.01" {
- &a := %delay_10s(0.1)
+ a := %delay_10s(0.1)
test_fail
}
# Regression test - Only the first child of the timeout block was executed
redundant {
timeout 1s {
- &b = true
- &c = true
+ b = true
+ c = true
}
}
-if (!(&b && &c)) {
+if (!(b && c)) {
test_fail
}
string test_string
string dummy_string
-&test_string := "AbCdE"
-&test_string := %tolower(%{test_string})
+test_string := "AbCdE"
+test_string := %tolower(%{test_string})
-if !(&test_string == "abcde") {
+if !(test_string == "abcde") {
test_fail
}
-&test_string := %tolower(AAbbCCdd)
-if !(&test_string == "aabbccdd") {
+test_string := %tolower(AAbbCCdd)
+if !(test_string == "aabbccdd") {
test_fail
}
#
# Doesn't exist
#
-&test_string := "%tolower(%{dummy_string})"
-if !(&test_string == "") {
+test_string := "%tolower(%{dummy_string})"
+if !(test_string == "") {
test_fail
}
string test_string
string dummy_string
-&test_string := "AbCdE"
-&test_string := %toupper(%{test_string})
-if (!(&test_string == "ABCDE")) {
+test_string := "AbCdE"
+test_string := %toupper(%{test_string})
+if (!(test_string == "ABCDE")) {
test_fail
}
-&test_string := %toupper(AAbbCCdd)
-if (!(&test_string == "AABBCCDD")) {
+test_string := %toupper(AAbbCCdd)
+if (!(test_string == "AABBCCDD")) {
test_fail
}
-&test_string := "%toupper(%{dummy_string})"
-if !(&test_string == "") {
+test_string := "%toupper(%{dummy_string})"
+if !(test_string == "") {
test_fail
}
string bar
transaction {
- &foo := "hello"
+ foo := "hello"
fail
- &bar := "nope"
+ bar := "nope"
}
#
# This shouldn't have been applied
#
-if &bar {
+if bar {
test_fail
}
#
# This should get rolled back, too!
#
-if &foo {
+if foo {
test_fail
} else {
ok # force auth success for the test framework
octets test_octets
string result_string
-&test_octets := 0x\
+test_octets := 0x\
d8abccb7834711af1de1812be2579febe946f5d7beef6fa5c7074c0cb917e9b91e23e14b016f27610097c16c0e0fad88176e077b24198c770746159\
05b8810d1c8b774d98889fa5c6027cde5e9c56dd4f7c48298c7713aeca5ba5dcfd506032ad05b1396f50e825b633d5a6af0dce6181b640287e03a65\
8734df46a86341556f28455b3f377313a5a2ac8c8267b8a5de559b95f9b493a68b9e0278485f9e3914d702b2b7b90ee85ff393461f197386d09b836\
test_fail
}
-&result_string := "%{1}"
+result_string := "%{1}"
if (!(%length(%{result_string}) == 8166)) {
test_fail
string bar
try {
- &foo := "hello"
+ foo := "hello"
fail
- &bar := "nope"
+ bar := "nope"
}
catch disallow {
test_fail
}
catch ok reject fail {
- if &foo != "hello" {
+ if foo != "hello" {
test_fail
}
- if &bar {
+ if bar {
test_fail
}
string foo
try { # ERROR
- &foo := "foo"
+ foo := "foo"
}
#
# No "catch" - that's an issue
#
-if &foo != "foo" {
+if foo != "foo" {
test_fail
}
\ No newline at end of file
#
# PRE: wimax
#
-&Vendor-Specific.FreeRADIUS.Proxied-To := 127.0.0.2
+Vendor-Specific.FreeRADIUS.Proxied-To := 127.0.0.2
#
# Check that a known but malformed attr is malformed
#
-&26.24757.84.9.5.7 := 0xab
+26.24757.84.9.5.7 := 0xab
-if (!(&26.24757.84.9.5.7 == 0xab)) {
+if (!(26.24757.84.9.5.7 == 0xab)) {
test_fail
}
#
# Check that an unknown attr is OK
#
-&26.24757.84.9.5.15 := 0xabcdef
+26.24757.84.9.5.15 := 0xabcdef
-if (!(&26.24757.84.9.5.15 == 0xabcdef)) {
+if (!(26.24757.84.9.5.15 == 0xabcdef)) {
test_fail
}
# Check that unknown attributes which are defined
# get automatically resolved to the real attribute.
#
-if (&26.11344.1 == 127.0.0.1) {
+if (26.11344.1 == 127.0.0.1) {
test_fail
}
-if (!(&26.11344.1 == 127.0.0.2)) {
+if (!(26.11344.1 == 127.0.0.2)) {
test_fail
}
-&26.11344.1 := 0x7f000001
+26.11344.1 := 0x7f000001
-if (&Vendor-Specific.FreeRADIUS.Proxied-To == 127.0.0.2) {
+if (Vendor-Specific.FreeRADIUS.Proxied-To == 127.0.0.2) {
test_fail
}
-if (!(&Vendor-Specific.FreeRADIUS.Proxied-To == 127.0.0.1)) {
+if (!(Vendor-Specific.FreeRADIUS.Proxied-To == 127.0.0.1)) {
test_fail
}
-if (&26.11344.1 == 127.0.0.2) {
+if (26.11344.1 == 127.0.0.2) {
test_fail
}
-if (!(&26.11344.1 == 127.0.0.1)) {
+if (!(26.11344.1 == 127.0.0.1)) {
test_fail
}
-&26.66.1 = 0x01020304
+26.66.1 = 0x01020304
-if (!(&26.66.1 == 0x01020304)) {
+if (!(26.66.1 == 0x01020304)) {
test_fail
}
#
# PRE: unknown-update
#
-if (&This-Does-Not-Exist == 1) { # ERROR
+if (This-Does-Not-Exist == 1) { # ERROR
test_fail
}
#
# This delayed binding should result in a parse error
#
-if (&User-Name == &Foo-Bar-Baz) { # ERROR
+if (User-Name == Foo-Bar-Baz) { # ERROR
test_fail
}
uint32 result_integer
string result_string
-&Framed-IP-Address := 127.0.0.1
-&test_octets := &Framed-IP-Address
+Framed-IP-Address := 127.0.0.1
+test_octets := Framed-IP-Address
-&test_string := %unpack(%{test_octets}, 0, 'ipaddr')
-&result_ipaddr := %unpack(%{test_octets}, 0, 'ipaddr')
+test_string := %unpack(%{test_octets}, 0, 'ipaddr')
+result_ipaddr := %unpack(%{test_octets}, 0, 'ipaddr')
-if !(&test_string == '127.0.0.1') {
+if !(test_string == '127.0.0.1') {
test_fail
}
-if !(&result_ipaddr == 127.0.0.1) {
+if !(result_ipaddr == 127.0.0.1) {
test_fail
}
-&test_octets := 0x000001020304
-&result_integer := %unpack(%{test_octets}, 4, 'uint16')
+test_octets := 0x000001020304
+result_integer := %unpack(%{test_octets}, 4, 'uint16')
# Octets 4 and 5 == 0x0304 == 772
-if ~(&result_integer == 772) {
+if ~(result_integer == 772) {
test_fail
}
# truncation
-&test_string := '0x0011223344556677'
-&result_string := %unpack(%{test_string}, 0, 'ether')
-if !(&result_string == '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
}
-&test_string := "0x48656C6C6F"
-&result_string := %unpack(%{test_string}, 0, 'string')
-if !(&result_string == 'Hello') {
+test_string := "0x48656C6C6F"
+result_string := %unpack(%{test_string}, 0, 'string')
+if !(result_string == 'Hello') {
test_fail
}
# Offset beyond data length
-&result_string := %unpack(%{test_string}, 10, 'string')
+result_string := %unpack(%{test_string}, 10, 'string')
-if (&result_string) {
+if (result_string) {
test_fail
}
-if (!(&Module-Failure-Message == 'unpack offset 10 is larger than input data length 5')) {
+if (!(Module-Failure-Message == 'unpack offset 10 is larger than input data length 5')) {
test_fail
}
-&request -= &Module-Failure-Message[*]
+request -= Module-Failure-Message[*]
# Invalid destination data type
-&result_string := %unpack(%{test_string}, 0, 'thing')
-if (&result_string) {
+result_string := %unpack(%{test_string}, 0, 'thing')
+if (result_string) {
test_fail
}
-if (!(&Module-Failure-Message == "Invalid data type 'thing'")) {
+if (!(Module-Failure-Message == "Invalid data type 'thing'")) {
test_fail
}
# Invalid source data type
-&result_string := %unpack(%{result_integer}, 0, 'string')
-if (&result_string) {
+result_string := %unpack(%{result_integer}, 0, 'string')
+if (result_string) {
test_fail
}
-if (!(&Module-Failure-Message == "unpack requires the input attribute to be 'string' or 'octets'")) {
+if (!(Module-Failure-Message == "unpack requires the input attribute to be 'string' or 'octets'")) {
test_fail
}
-&request -= &Module-Failure-Message[*]
+request -= Module-Failure-Message[*]
# Invalid hex string
-&test_string := '0x014sdgw'
-&result_string := %unpack(%{test_string}, 0, 'string')
+test_string := '0x014sdgw'
+result_string := %unpack(%{test_string}, 0, 'string')
-if (&result_string) {
+if (result_string) {
test_fail
}
-if (!(&Module-Failure-Message == "Invalid hex string in '0x014sdgw'")) {
+if (!(Module-Failure-Message == "Invalid hex string in '0x014sdgw'")) {
test_fail
}
-&request -= &Module-Failure-Message[*]
+request -= Module-Failure-Message[*]
# Zero length hex string
-&test_string := '0x'
-&result_string := %unpack(%{test_string}, 0, 'string')
+test_string := '0x'
+result_string := %unpack(%{test_string}, 0, 'string')
-if (&result_string) {
+if (result_string) {
test_fail
}
-if (!(&Module-Failure-Message == "Zero length hex string in '0x'")) {
+if (!(Module-Failure-Message == "Zero length hex string in '0x'")) {
test_fail
}
# Tests of extracting multiple values
-&test_octets := 0x0011223344556677
-&NAS-Port := %unpack(%{test_octets}, 0, 'uint8', '*')
+test_octets := 0x0011223344556677
+NAS-Port := %unpack(%{test_octets}, 0, 'uint8', '*')
-if (&NAS-Port[#] != 8) {
+if (NAS-Port[#] != 8) {
test_fail
}
-if !((&NAS-Port[0] == 0) && (&NAS-Port[1] == 17) && (&NAS-Port[2] == 34) && (&NAS-Port[3] == 51) && (&NAS-Port[4] == 68) && (&NAS-Port[5] == 85) && (&NAS-Port[6] == 102) && (&NAS-Port[7] == 119)) {
+if !((NAS-Port[0] == 0) && (NAS-Port[1] == 17) && (NAS-Port[2] == 34) && (NAS-Port[3] == 51) && (NAS-Port[4] == 68) && (NAS-Port[5] == 85) && (NAS-Port[6] == 102) && (NAS-Port[7] == 119)) {
test_fail
}
-&NAS-Port := %unpack(%{test_octets}, 0, 'uint8', 2)
+NAS-Port := %unpack(%{test_octets}, 0, 'uint8', 2)
-if (&NAS-Port[#] != 2) {
+if (NAS-Port[#] != 2) {
test_fail
}
-&NAS-Port := %unpack(%{test_octets}, 0, 'uint8', 10)
+NAS-Port := %unpack(%{test_octets}, 0, 'uint8', 10)
-if (&NAS-Port[#] != 8) {
+if (NAS-Port[#] != 8) {
test_fail
}
-&NAS-Port := %unpack(%{test_octets}, 0, 'uint8', 'invalid')
+NAS-Port := %unpack(%{test_octets}, 0, 'uint8', 'invalid')
-if (&NAS-Port) {
+if (NAS-Port) {
test_fail
}
update control {
- &Password.Cleartext := 'hello'
+ Password.Cleartext := 'hello'
}
success
# A more generic "update" mechanism
#
update {
- &control.Password.Cleartext := 'hello'
+ control.Password.Cleartext := 'hello'
}
success
#
update request {
- &Class := 0x01020304
- &Class += 0x05060708
- &Class += 0x090a0b0c
+ Class := 0x01020304
+ Class += 0x05060708
+ Class += 0x090a0b0c
}
#
update request {
- &Proxy-State += &Class[0]
- &Proxy-State += &Class[1]
- &Proxy-State += &Class[2]
+ Proxy-State += Class[0]
+ Proxy-State += Class[1]
+ Proxy-State += Class[2]
}
-if (!(&Proxy-State == 0x01020304)) {
+if (!(Proxy-State == 0x01020304)) {
test_fail
}
# Must be the same as above
-if (!(&Proxy-State[0] == 0x01020304)) {
+if (!(Proxy-State[0] == 0x01020304)) {
test_fail
}
-if (!(&Proxy-State[1] == 0x05060708)) {
+if (!(Proxy-State[1] == 0x05060708)) {
test_fail
}
-if (!(&Proxy-State[2] == 0x090a0b0c)) {
+if (!(Proxy-State[2] == 0x090a0b0c)) {
test_fail
}
# must not exist
-if (&Proxy-State[3]) {
+if (Proxy-State[3]) {
test_fail
}
#
update request {
- &Filter-Id := 'foobarbaz'
- &NAS-Port := 123456789
- &Framed-IP-Address := 192.0.2.1
+ Filter-Id := 'foobarbaz'
+ NAS-Port := 123456789
+ Framed-IP-Address := 192.0.2.1
}
-if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789)) || (!(&Framed-IP-Address == 192.0.2.1))) {
+if (!((Filter-Id == 'foobarbaz')) || (!(NAS-Port == 123456789)) || (!(Framed-IP-Address == 192.0.2.1))) {
test_fail
}
# Remove all attributes in the control list
update {
- &request !* ANY
+ request !* ANY
}
# All attributes should now of been removed
-if ((&Filter-Id && (&Filter-Id == 'foobarbaz')) || \
- (&NAS-Port && (&NAS-Port == 123456789)) || \
- (&Framed-IP-Address && (&Framed-IP-Address == 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
}
# This will of been removed too
update request {
- &User-Password := 'hello'
+ User-Password := 'hello'
}
success
# PRE: update
#
update control {
- &NAS-Port := 5
- &NAS-Port += 10
- &NAS-Port += 15
- &NAS-Port += 20
- &Filter-Id := 'foo'
- &Filter-Id += 'baz'
- &Filter-Id += '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
-&request := &control
+request := control
#
# @fixme - EDIT - all kinds of other things are broken, and no time currently to debug them.
# Integer ==
#
update request {
- &NAS-Port == 10
+ NAS-Port == 10
}
-if (!(&NAS-Port[0] == 10)) {
+if (!(NAS-Port[0] == 10)) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
#
# String ==
#
update request {
- &Filter-Id == 'baz'
+ Filter-Id == 'baz'
}
-if (!(&Filter-Id[0] == 'baz')) {
+if (!(Filter-Id[0] == 'baz')) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
#
# Integer <
#
update request {
- &NAS-Port < 10
+ NAS-Port < 10
}
-if (!(&NAS-Port[0] == 5)) {
+if (!(NAS-Port[0] == 5)) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
#
# Integer >
#
update request {
- &NAS-Port > 10
+ NAS-Port > 10
}
-if (!(&NAS-Port[0] == 15)) {
+if (!(NAS-Port[0] == 15)) {
test_fail
}
-if (!(&NAS-Port[1] == 20)) {
+if (!(NAS-Port[1] == 20)) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
#
# Integer <=
#
update request {
- &NAS-Port <= 10
+ NAS-Port <= 10
}
-if (!(&NAS-Port[0] == 5)) {
+if (!(NAS-Port[0] == 5)) {
test_fail
}
-if (!(&NAS-Port[1] == 10)) {
+if (!(NAS-Port[1] == 10)) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
#
# Integer >=
#
update request {
- &NAS-Port >= 10
+ NAS-Port >= 10
}
-if (!(&NAS-Port[0] == 10)) {
+if (!(NAS-Port[0] == 10)) {
test_fail
}
-if (!(&NAS-Port[1] == 15)) {
+if (!(NAS-Port[1] == 15)) {
test_fail
}
-if (!(&NAS-Port[2] == 20)) {
+if (!(NAS-Port[2] == 20)) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
#
# Integer !=
#
update request {
- &NAS-Port != 10
+ NAS-Port != 10
}
-if (!(&NAS-Port[0] == 5)) {
+if (!(NAS-Port[0] == 5)) {
test_fail
}
-if (!(&NAS-Port[1] == 15)) {
+if (!(NAS-Port[1] == 15)) {
test_fail
}
-if (!(&NAS-Port[2] == 20)) {
+if (!(NAS-Port[2] == 20)) {
test_fail
}
}
# Reset the request list
-&request := &control
+request := control
update request {
- &Callback-Id := 'baz'
- &Callback-Id += 'boink'
+ Callback-Id := 'baz'
+ Callback-Id += 'boink'
}
#
# String (Intersection)
#
update request {
- &Filter-Id == &Callback-Id[0]
+ Filter-Id == Callback-Id[0]
}
-if (!(&Filter-Id[0] == &Callback-Id[0])) {
+if (!(Filter-Id[0] == Callback-Id[0])) {
test_fail
}
}
update control {
- &Auth-Type := ::Accept
+ Auth-Type := ::Accept
}
success
#
# This was parsed in the old edit code, but never did anything!
#
- &Tmp-Group-0 := { # ERROR
+ Tmp-Group-0 := { # ERROR
Filter-Id = "foo"
}
}
-if !&reply.Tmp-Group-0.Filter-Id {
+if !reply.Tmp-Group-0.Filter-Id {
test_fail
}
#
# This is a string, so it's NOT allowed.
#
- &Filter-Id := { # ERROR
+ Filter-Id := { # ERROR
Reply-Message := "1.0"
}
}
#
update {
- &Filter-Id := 0x626f62
+ Filter-Id := 0x626f62
}
-if (!(&Filter-Id == 'bob')) {
+if (!(Filter-Id == 'bob')) {
test_fail
}
update {
- &Filter-Id := '0x626f62'
+ Filter-Id := '0x626f62'
}
-if (!(&Filter-Id == '0x626f62')) {
+if (!(Filter-Id == '0x626f62')) {
test_fail
}
# PRE: update
#
update {
- &control.Reply-Message += 'a'
- &control.Reply-Message += 'b'
- &control.Reply-Message += 'c'
+ control.Reply-Message += 'a'
+ control.Reply-Message += 'b'
+ control.Reply-Message += 'c'
}
-if (!((&control.Reply-Message[0] == 'a')) || (!(&control.Reply-Message[1] == 'b')) || (!(&control.Reply-Message[2] == 'c'))) {
+if (!((control.Reply-Message[0] == 'a')) || (!(control.Reply-Message[1] == 'b')) || (!(control.Reply-Message[2] == 'c'))) {
test_fail
}
# Overwrite a specific index, and check the value here is replaced
update {
- &control.Reply-Message[1] := 'd'
+ control.Reply-Message[1] := 'd'
}
-if (!((&control.Reply-Message[0] == 'a')) || (!(&control.Reply-Message[1] == 'd')) || (!(&control.Reply-Message[2] == 'c'))) {
+if (!((control.Reply-Message[0] == 'a')) || (!(control.Reply-Message[1] == 'd')) || (!(control.Reply-Message[2] == 'c'))) {
test_fail
}
# Check isolation...
update {
- &control.Reply-Message[0] := &control.Reply-Message[0]
+ control.Reply-Message[0] := control.Reply-Message[0]
}
-if (!((&control.Reply-Message[0] == 'a')) || (!(&control.Reply-Message[1] == 'd')) || (!(&control.Reply-Message[2] == 'c'))) {
+if (!((control.Reply-Message[0] == 'a')) || (!(control.Reply-Message[1] == 'd')) || (!(control.Reply-Message[2] == 'c'))) {
test_fail
}
# It's an error to update lists that don't exist.
#
update {
- &request := &reply
- &control += &request
- &reply !* ANY
+ request := reply
+ control += request
+ reply !* ANY
}
update {
- &request := nope # ERROR
+ request := nope # ERROR
}
-&request += { &User-Password = 'hello' }
+request += { User-Password = 'hello' }
success
# Form attribute references with xlats
#
update request {
- &Filter-Id += 'foo'
- &Filter-Id += 'bar'
- &Reply-Message += 'baz'
+ Filter-Id += 'foo'
+ Filter-Id += 'bar'
+ Reply-Message += 'baz'
#
# @fixme - EDIT - how the heck did this ever work?
#
- &control !* ANY
+ control !* ANY
}
-if (!(&Filter-Id[0] == 'foo')) {
+if (!(Filter-Id[0] == 'foo')) {
test_fail
}
# Now delete the LHS by assigning the control list to it (which is empty)
update {
- &request := &control
+ request := control
}
-if (&Filter-Id || &Reply-Message) {
+if (Filter-Id || Reply-Message) {
test_fail
}
# State doesn't exist, so Class shouldn't be created
#
update request {
- &Class := &State
+ Class := State
}
-if (&Class) {
+if (Class) {
test_fail
}
#
#
update request {
- &Filter-Id := "%{Reply-Message}"
+ Filter-Id := "%{Reply-Message}"
}
-if (!&Filter-Id) {
+if (!Filter-Id) {
test_fail
}
-if (!(&Filter-Id == '')) {
+if (!(Filter-Id == '')) {
test_fail
}
# @fixme - EDIT - the new method is to simply omit the assignment
#
update request {
- &Class := "%{Reply-Message}"
+ Class := "%{Reply-Message}"
}
-if (!(&Class == "")) {
+if (!(Class == "")) {
test_fail
}
# Define initial test strings
update control {
- &Filter-Id := 'foo'
- &Filter-Id += '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
-# &Filter-Id += &control.Filter-Id 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 {
- &Filter-Id !* ANY
- &Filter-Id += &control.Filter-Id[0]
- &Filter-Id += &control.Filter-Id[1]
+ Filter-Id !* ANY
+ Filter-Id += control.Filter-Id[0]
+ Filter-Id += control.Filter-Id[1]
}
# Prepend a single value
update request {
- &Filter-Id ^= 'boink'
+ Filter-Id ^= 'boink'
}
# The prepended value should be first followed by the other two
-if (!((&Filter-Id[0] == 'boink')) || (!(&Filter-Id[1] == 'foo')) || (!(%{Filter-Id[2]} == 'baz'))) {
+if (!((Filter-Id[0] == 'boink')) || (!(Filter-Id[1] == 'foo')) || (!(%{Filter-Id[2]} == 'baz'))) {
test_fail
}
# Add an extra element to the start of control
update control {
- &Filter-Id ^= 'wibble'
+ Filter-Id ^= 'wibble'
}
# Prepend control to request
update {
- &request ^= &control
+ request ^= control
}
# The attributes should now be "wibble", "foo", "baz", "boink", "foo", "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'))) {
+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
}
# Set up an attribute in control with a single value
update control {
- &Filter-Id := 'initial'
+ Filter-Id := 'initial'
}
# Prepend the list of Filter-Id from request to the new attribute
#update {
-# &control.Filter-Id ^= &Filter-Id
+# control.Filter-Id ^= Filter-Id
#}
# (Temporary method to achieve the same - as per issue noted above)
update {
- &control ^= &request
+ control ^= request
}
# The control attributes should now be "wibble", "foo", "baz", "boink", "foo", "baz", "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'))) {
+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
}
# PRE: update
#
update {
- &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
+ 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 (!((&Framed-IP-Address[0] == 192.0.2.1)) || (!(&Framed-IP-Address[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 {
- &Framed-IP-Address !* ANY
+ Framed-IP-Address !* ANY
}
# Non Framed-IP-Address address attributes should still be in the request list
-if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789))) {
+if (!((Filter-Id == 'foobarbaz')) || (!(NAS-Port == 123456789))) {
test_fail
}
# There should be no Framed-IP-Address attributes in the request list
-if (&Framed-IP-Address) {
+if (Framed-IP-Address) {
test_fail
}
# But there should still be some in the control list
-if (!((&control.Framed-IP-Address == 192.0.2.1)) || (!(&control.Framed-IP-Address[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.Framed-IP-Address !* ANY
- &control.Login-IP-Host !* ANY
+ control.Framed-IP-Address !* ANY
+ control.Login-IP-Host !* ANY
}
-if (&control.Framed-IP-Address || &control.Login-IP-Host) {
+if (control.Framed-IP-Address || control.Login-IP-Host) {
test_fail
}
#
update request {
- &Filter-Id := 'foobarbaz'
- &NAS-Port := 123456789
- &Framed-IP-Address := 192.0.2.1
+ Filter-Id := 'foobarbaz'
+ NAS-Port := 123456789
+ Framed-IP-Address := 192.0.2.1
}
-if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789)) || (!(&Framed-IP-Address == 192.0.2.1))) {
+if (!((Filter-Id == 'foobarbaz')) || (!(NAS-Port == 123456789)) || (!(Framed-IP-Address == 192.0.2.1))) {
test_fail
}
# Remove all attributes in the control list
update {
- &request !* ANY
+ request !* ANY
}
# All attributes should now of been removed
-if ((&Filter-Id && (&Filter-Id == 'foobarbaz')) || \
- (&NAS-Port && (&NAS-Port == 123456789)) || \
- (&Framed-IP-Address && (&Framed-IP-Address == 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
}
# This will of been removed too
update request {
- &User-Password := 'hello'
+ User-Password := 'hello'
}
success
#
update {
- &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
+ 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 (!((&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))) {
+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 Framed-IP-Address with a specific value
update {
- &Framed-IP-Address -= 192.0.2.1
+ Framed-IP-Address -= 192.0.2.1
}
# 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])) {
+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 Framed-IP-Address with a specific value (somewhere in the middle)
update {
- &Framed-IP-Address -= 192.0.2.3
+ Framed-IP-Address -= 192.0.2.3
}
# 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])) {
+if (!((Framed-IP-Address[0] == 192.0.2.2)) || \
+ (!(Framed-IP-Address[1] == 192.0.2.4)) || \
+ (Framed-IP-Address[2])) {
test_fail
}
# Remove Framed-IP-Address with a specific value (which doesn't exist)
update {
- &Framed-IP-Address -= 192.0.2.3
+ Framed-IP-Address -= 192.0.2.3
}
# 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])) {
+if (!((Framed-IP-Address[0] == 192.0.2.2)) || \
+ (!(Framed-IP-Address[1] == 192.0.2.4)) || \
+ (Framed-IP-Address[2])) {
test_fail
}
# Remove NAS-IP-Address (which doesn't exist - more to check for SEGV/assert)
update {
- &NAS-IP-Address -= 192.0.2.3
+ NAS-IP-Address -= 192.0.2.3
}
# Remove Framed-IP-Address with a specific value
update {
- &Framed-IP-Address -= 192.0.2.4
+ Framed-IP-Address -= 192.0.2.4
}
# 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])) {
+if (!((Framed-IP-Address[0] == 192.0.2.2)) || \
+ (Framed-IP-Address[1])) {
test_fail
}
# Remove Framed-IP-Address with a specific value
update {
- &Framed-IP-Address -= 192.0.2.2
+ Framed-IP-Address -= 192.0.2.2
}
# 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) {
+if (Framed-IP-Address) {
test_fail
}
# Non Framed-IP-Address address attributes should still be in the request list
-if (!((&Filter-Id == 'foobarbaz')) || (!(&NAS-Port == 123456789))) {
+if (!((Filter-Id == 'foobarbaz')) || (!(NAS-Port == 123456789))) {
test_fail
}
# But there should still be some in the control list
-if (!((&control.Framed-IP-Address[0] == 192.0.2.1)) || (!(&control.Framed-IP-Address[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
}
-&Filter-Id := "foo"
+Filter-Id := "foo"
update request {
- &Filter-Id !* ANY
+ Filter-Id !* ANY
}
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
-&Filter-Id := "foo"
-&reply.Filter-Id := "bar"
+Filter-Id := "foo"
+reply.Filter-Id := "bar"
update {
- &request.Filter-Id !* ANY
- &reply.[*] !* ANY
+ request.Filter-Id !* ANY
+ reply.[*] !* ANY
}
-if (&Filter-Id) {
+if (Filter-Id) {
test_fail
}
-if (&reply.Filter-Id) {
+if (reply.Filter-Id) {
test_fail
}
update reply {
- &NAS-Port := 12
+ NAS-Port := 12
}
-if (!&reply.NAS-Port) {
+if (!reply.NAS-Port) {
test_fail
}
update reply {
- &NAS-Port += 13
+ NAS-Port += 13
}
-if (!(&reply.NAS-Port[0] == 12)) {
+if (!(reply.NAS-Port[0] == 12)) {
test_fail
}
-if (!(&reply.NAS-Port[1] == 13)) {
+if (!(reply.NAS-Port[1] == 13)) {
test_fail
}
#
# Clear out reply as we don't care about the attributes in it.
#
-&reply := {}
+reply := {}
success
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_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
}
-&result_string := "%urlunquote(%{test_string1})"
-if (!(&result_string == &test_string1)) {
+result_string := "%urlunquote(%{test_string1})"
+if (!(result_string == test_string1)) {
test_fail
}
-&result_string := "%urlquote(%{test_string2})"
-if (!(&result_string == &encoded_string2)) {
+result_string := "%urlquote(%{test_string2})"
+if (!(result_string == encoded_string2)) {
test_fail
}
-&result_string := "%urlquote(%{test_string3})"
-if (!(&result_string == &encoded_string3)) {
+result_string := "%urlquote(%{test_string3})"
+if (!(result_string == encoded_string3)) {
test_fail
}
-&result_string := "%urlunquote(%{encoded_string2})"
-if (!(&result_string == &test_string2)) {
+result_string := "%urlunquote(%{encoded_string2})"
+if (!(result_string == test_string2)) {
test_fail
}
-&result_string := "%urlunquote(%{encoded_string3})"
-if (!(&result_string == &test_string3)) {
+result_string := "%urlunquote(%{encoded_string3})"
+if (!(result_string == test_string3)) {
test_fail
}
-&result_string := "%urlunquote(%%E,123)"
+result_string := "%urlunquote(%%E,123)"
# Test decoding invalid encoded string
-if !(&result_string == "") {
+if !(result_string == "") {
test_fail
}
# Tests for Vendor-Specific
#
-&raw.26 := 0x01020304
+raw.26 := 0x01020304
-if (!&raw.26) {
+if (!raw.26) {
test_fail
}
-elsif (!(&raw.26 == 0x01020304)) {
+elsif (!(raw.26 == 0x01020304)) {
test_fail
}
else {
#
# Alias from Cisco -> Vendor-Specific.Cisco
#
-&Cisco.AVPair := "foo"
+Cisco.AVPair := "foo"
-if !(&Vendor-Specific.Cisco.AVPair == "foo") {
+if !(Vendor-Specific.Cisco.AVPair == "foo") {
test_fail
}
-&Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Port := 6809
+Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Port := 6809
-if (!(&Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Port == 6809)) {
+if (!(Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Port == 6809)) {
test_fail
}
-&26.24757.84.9.5.7 := 0x01
-if (!(&Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Assigned == 1)) {
+26.24757.84.9.5.7 := 0x01
+if (!(Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Assigned == 1)) {
test_fail
}
#
string result_string
-&Filter-Id := "foo"
-&NAS-Identifier := "bar"
+Filter-Id := "foo"
+NAS-Identifier := "bar"
#
# First choice
#
-&result_string := "%{&Filter-Id || &NAS-Identifier}"
-if (!(&result_string == 'foo')) {
+result_string := "%{Filter-Id || NAS-Identifier}"
+if (!(result_string == 'foo')) {
test_fail
}
#
# Second choice
#
-&request -= &Filter-Id[*]
-&result_string := "%{&Filter-Id || &NAS-Identifier}"
-if (!(&result_string == 'bar')) {
+request -= Filter-Id[*]
+result_string := "%{Filter-Id || NAS-Identifier}"
+if (!(result_string == 'bar')) {
test_fail
}
#
# Multiple things in an alternation
#
-&result_string := %{%{Filter-Id} || "%{NAS-Identifier} foo"}
-if (!(&result_string == 'bar foo')) {
+result_string := %{%{Filter-Id} || "%{NAS-Identifier} foo"}
+if (!(result_string == 'bar foo')) {
test_fail
}
#
# Alternation is empty
#
-&result_string := "%{&Filter-Id || ''}"
-if (!(&result_string == '')) {
+result_string := "%{Filter-Id || ''}"
+if (!(result_string == '')) {
test_fail
}
#
# Everything null
#
-&request -= &NAS-Identifier[*]
+request -= NAS-Identifier[*]
#
# Both sides are failing, so the assignment returns a NULL string
#
-&result_string := "%{&Filter-Id || &NAS-Identifier}"
-if (!(&result_string == "")) {
+result_string := "%{Filter-Id || NAS-Identifier}"
+if (!(result_string == "")) {
test_fail
}
#
# And unquoted results return nothing.
#
-&result_string := %{&Filter-Id || &NAS-Identifier}
-if (&result_string) {
+result_string := %{Filter-Id || NAS-Identifier}
+if (result_string) {
test_fail
}
# Everything null
#
string result_string
-&request -= &Filter-Id[*]
-&request -= &NAS-Identifier[*]
+request -= Filter-Id[*]
+request -= NAS-Identifier[*]
-&result_string := "%{&Filter-Id[0] || &NAS-Identifier[0]}%delay_10s()"
+result_string := "%{Filter-Id[0] || NAS-Identifier[0]}%delay_10s()"
success
string test_string2
string dummy_string
-&test_string1 := "foo"
-&test_string2 := "bar"
+test_string1 := "foo"
+test_string2 := "bar"
if (!(%{%test.passthrough(%{test_string1}) || %{test_string2}} == 'foo')) {
test_fail
-&request += {
- &Framed-IP-Address = 192.0.2.1
- &Framed-IP-Address = 192.0.2.2
+request += {
+ Framed-IP-Address = 192.0.2.1
+ Framed-IP-Address = 192.0.2.2
}
if (!(%{Framed-IP-Address[#]} == 2)) {
test_fail
}
-if (!((&Framed-IP-Address[0] == 192.0.2.1)) || (!(&Framed-IP-Address[1] == 192.0.2.2))) {
+if (!((Framed-IP-Address[0] == 192.0.2.1)) || (!(Framed-IP-Address[1] == 192.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 += {
- &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[#]}
+request += {
+ 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 (!(&Filter-Id == '192.0.2.1,192.0.2.2')) {
+if (!(Filter-Id == '192.0.2.1,192.0.2.2')) {
test_fail
}
-if (!(&NAS-Port == 2)) {
+if (!(NAS-Port == 2)) {
test_fail
}
-&request += {
- &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
+request += {
+ 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 (%{Framed-IP-Address[#]} != 4) {
string result_string
uint32 result_integer
-&result_string := "%config(modules.static.test.boolean)"
-if (!(&result_string == "no")) {
+result_string := "%config(modules.static.test.boolean)"
+if (!(result_string == "no")) {
test_fail
}
-&result_string := "test"
-&result_integer := %config(modules.static.%{result_string}.integer)
-if (!(&result_integer == 1)) {
+result_string := "test"
+result_integer := %config(modules.static.%{result_string}.integer)
+if (!(result_integer == 1)) {
test_fail
}
%delay_10s() # Should 'blip' the request
-&result_float := %delay_10s(0.1)
-if (!&result_float) {
+result_float := %delay_10s(0.1)
+if (!result_float) {
fail
}
#
# Check the delay was ~100ms
#
-if (&result_float < 0.1) {
+if (result_float < 0.1) {
fail
}
#
octets test_octets
-&test_octets := 0x520d0103abcdef0206010203040506
+test_octets := 0x520d0103abcdef0206010203040506
# the protocol decoder puts the attributes into a flat namespace
if (!(%dhcpv4.decode(%{test_octets}) == 1)) {
test_fail
}
-if !(&Relay-Agent-Information.Circuit-Id == 0xabcdef) {
+if !(Relay-Agent-Information.Circuit-Id == 0xabcdef) {
test_fail
}
-if !(&Relay-Agent-Information.Remote-Id == 0x010203040506) {
+if !(Relay-Agent-Information.Remote-Id == 0x010203040506) {
test_fail
}
#
# Encode all of the Relay-Agent-Information suboptions
#
-&test_octets := %dhcpv4.encode(&request.Relay-Agent-Information.[*])
+test_octets := %dhcpv4.encode(request.Relay-Agent-Information.[*])
-if !(&test_octets == 0x520d0103abcdef0206010203040506) {
+if !(test_octets == 0x520d0103abcdef0206010203040506) {
test_fail
}
# Regression test for double consecutive alternations
uint64 result_int64
-&result_int64 := "%{&Acct-Input-Octets || "2"}%{&Acct-Input-Gigawords || "1"}"
-if (!(&result_int64 == 21)) {
+result_int64 := "%{Acct-Input-Octets || "2"}%{Acct-Input-Gigawords || "1"}"
+if (!(result_int64 == 21)) {
test_fail
}
-&request += {
- &Filter-Id = 'foo'
- &Filter-Id = 'bar'
- &NAS-Port = '4'
- &NAS-Port = '8'
- &NAS-Port = '1'
-
- &Reply-Message = '%{Filter-Id}'
+request += {
+ Filter-Id = 'foo'
+ Filter-Id = 'bar'
+ NAS-Port = '4'
+ NAS-Port = '8'
+ NAS-Port = '1'
+
+ Reply-Message = '%{Filter-Id}'
}
#
uint32 idx
string stackstr
- &idx := 1
+ idx := 1
if (!(%eval("\%{Filter-Id[%{idx}]}") == 'bar')) {
test_fail
}
- &stackstr := 'foo'
+ stackstr := 'foo'
if (!(%eval("\%{stackstr}") == 'foo')) {
test_fail
string test_string
string result_string
-&test_string = "foo"
-&result_string := %exec('/bin/echo', "hello 1234:%{test_string} world")
+test_string = "foo"
+result_string := %exec('/bin/echo', "hello 1234:%{test_string} world")
-if (!(&result_string == "hello 1234:foo world")) {
+if (!(result_string == "hello 1234:foo world")) {
test_fail
}
-&result_string := %exec('/bin/echo', "hello %{test_string}:1234 world")
-if (!(&result_string == "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
-&result_string := %exec('/bin/echo', "%{User-Password}")
-if (!(&result_string == &User-Password)) {
+result_string := %exec('/bin/echo', "%{User-Password}")
+if (!(result_string == User-Password)) {
test_fail
} else {
- &User-Password := "hello"
+ User-Password := "hello"
}
success
#
string result_string
-&request += {
- &Class = '1=1|my_attr=2|my_attr=hello|'
- &Calling-Station-ID = '|'
+request += {
+ Class = '1=1|my_attr=2|my_attr=hello|'
+ Calling-Station-ID = '|'
}
-&control += {
- &User-Name = '|hello|goodbye'
- &User-Name = '|morning|night|1|'
- &Reply-Message = 'Can\'t touch this'
- &Filter-Id = 'here. are . some. words. '
+control += {
+ User-Name = '|hello|goodbye'
+ User-Name = '|morning|night|1|'
+ Reply-Message = 'Can\'t touch this'
+ Filter-Id = 'here. are . some. words. '
}
-&result_string := "%concat(%explode(%{Class}, '|'), ',')"
-if (!(&result_string == "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
}
-&result_string := "%concat(%explode(%{Calling-Station-ID}, '|'), ',')"
-if (!(&result_string == "")) {
+result_string := "%concat(%explode(%{Calling-Station-ID}, '|'), ',')"
+if (!(result_string == "")) {
test_fail
}
-&result_string := "%concat(%explode(%{control.User-Name[*]}, |), ',')"
-if (!(&result_string == "hello,goodbye,morning,night,1")) {
+result_string := "%concat(%explode(%{control.User-Name[*]}, |), ',')"
+if (!(result_string == "hello,goodbye,morning,night,1")) {
test_fail
}
-&result_string := "%concat(%explode(%{control.Reply-Message}, |), ',')"
-if !(&result_string == 'Can\'t touch this') {
+result_string := "%concat(%explode(%{control.Reply-Message}, |), ',')"
+if !(result_string == 'Can\'t touch this') {
test_fail
}
-&result_string := "%concat(%explode(%{control.Filter-Id}, '. '), ',')"
-if !(&result_string == '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
uint32 test_integer
-&test_integer := %debug(4)
+test_integer := %debug(4)
# Check debug level is now 4
if (!(%debug(4) == 4)) {
}
# Check for 'splosions
-"%{&control.Password.Cleartext || &control.User-Name}"
-"%{&control.User-Name || &control.Password.Cleartext}"
+"%{control.Password.Cleartext || control.User-Name}"
+"%{control.User-Name || control.Password.Cleartext}"
-if (&control.Password.Cleartext =~ /(h)(e)(l)(l)(o)/) {
+if (control.Password.Cleartext =~ /(h)(e)(l)(l)(o)/) {
"%{0}"
"%{1}"
"%{2}"
string result_string
uint32 result_integer
-&result_string := "%interpreter(.filename)"
-&result_integer := "%interpreter(.line)"
+result_string := "%interpreter(.filename)"
+result_integer := "%interpreter(.line)"
-if (!(&result_string == "src/tests/keywords/xlat-interpreter")) {
+if (!(result_string == "src/tests/keywords/xlat-interpreter")) {
test_fail
}
-&result_string := "%interpreter(.name)"
-if (!(&result_string == "&result_string")) {
+result_string := "%interpreter(.name)"
+if (!(result_string == "result_string")) {
test_fail
}
-&result_string := "%interpreter(.type)"
-if (!(&result_string == "edit")) {
+result_string := "%interpreter(.type)"
+if (!(result_string == "edit")) {
test_fail
}
-if (!(&result_integer == 11)) {
+if (!(result_integer == 11)) {
test_fail
}
-&control := {
- &Framed-IP-Address = 192.0.2.1
- &Framed-IP-Address = 192.0.2.2
+control := {
+ 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 += {
- &NAS-IP-Address = %{control.[1]}
- &NAS-IP-Address = %{control.[0]}
- &Filter-Id = %concat(%{control.[*]}, ',')
- &NAS-Port = %{control.[#]}
+request += {
+ NAS-IP-Address = %{control.[1]}
+ NAS-IP-Address = %{control.[0]}
+ Filter-Id = %concat(%{control.[*]}, ',')
+ NAS-Port = %{control.[#]}
}
-if !(&Filter-Id == '192.0.2.1,192.0.2.2') {
+if !(Filter-Id == '192.0.2.1,192.0.2.2') {
test_fail
}
-if !(&NAS-Port == 2) {
+if !(NAS-Port == 2) {
test_fail
}
# Regression test for 0x prefix. xlat expanded
# octet strings must NOT have a 0x prefix added
#
-&request += {
- &Class = 0x0001020304050607
- &Class = 0x0706050403020100
+request += {
+ Class = 0x0001020304050607
+ Class = 0x0706050403020100
}
-if (!(&Class == 0x0001020304050607)) {
+if (!(Class == 0x0001020304050607)) {
test_fail
}
-if (!(&Class[0] == 0x0001020304050607)) {
+if (!(Class[0] == 0x0001020304050607)) {
test_fail
}
string printable
string unprintable
-&printable = "🍩abcdef🍩"
-&unprintable = "\t🍩\n"
+printable = "🍩abcdef🍩"
+unprintable = "\t🍩\n"
# Relaxed mode allows tabs and spaces
if (!%str.printable("\t 🍩", "yes")) {
octets test_octets6
string result_string
-&test_octets1 := 0x5c5c
-&test_octets2 := 0x49206c696b6520636869636b656e2049206c696b65206c69766572
-&test_octets3 := 0x490049
-&test_octets4 = 0x00
-&test_octets5 = 0x7465737431
-&test_octets6 = 0x7465737432
+test_octets1 := 0x5c5c
+test_octets2 := 0x49206c696b6520636869636b656e2049206c696b65206c69766572
+test_octets3 := 0x490049
+test_octets4 = 0x00
+test_octets5 = 0x7465737431
+test_octets6 = 0x7465737432
-&result_string := %{(string) %{test_octets1}}
-if (!(&result_string == "\\\\")) {
+result_string := %{(string) %{test_octets1}}
+if (!(result_string == "\\\\")) {
test_fail
}
#
# We don't need %{(string) ...) either.
#
-if !("%{(string) &test_octets5}%{(string) &test_octets6}" == "test1test2") {
+if !("%{(string) test_octets5}%{(string) test_octets6}" == "test1test2") {
test_fail
}
test_fail
}
-&result_string := %{(string) %{test_octets2}}
-if !(&result_string == 'I like chicken I like liver') {
+result_string := %{(string) %{test_octets2}}
+if !(result_string == 'I like chicken I like liver') {
test_fail
}
-&result_string := %{(string) %{test_octets3}}
-if (!(&result_string == "I\000I")) {
+result_string := %{(string) %{test_octets3}}
+if (!(result_string == "I\000I")) {
test_fail
}
-&result_string := %{(string) %{test_octets4}}
-if (!(&result_string == "\000")) {
+result_string := %{(string) %{test_octets4}}
+if (!(result_string == "\000")) {
test_fail
}
string test_string3
string empty_string
-&test_string1 := 'aaa'
-&test_string2 := "\n\n\n"
-&test_string3 := "the quick brown fox jumped over the lazy dog"
-&empty_string := ''
+test_string1 := 'aaa'
+test_string2 := "\n\n\n"
+test_string3 := "the quick brown fox jumped over the lazy dog"
+empty_string := ''
#
# Non-regex base substitutions
# PRE: update escape
#
update reply {
- &Vendor-Specific.WiMAX.Capability.Release = "foo"
+ Vendor-Specific.WiMAX.Capability.Release = "foo"
}
#
# reference here should be to an unknown attribute,
# and the dereference should fail.
#
-if (&reply.Capability.Release == "foo") { # ERROR
+if (reply.Capability.Release == "foo") { # ERROR
test_fail
}
else {
string valid_utf8
string invalid_utf8
-&valid_utf8 = "🍩abcdef🍩\n\t"
-&invalid_utf8 = "🍩\x80"
+valid_utf8 = "🍩abcdef🍩\n\t"
+invalid_utf8 = "🍩\x80"
if (%str.utf8("\xFE")) {
test_fail