-#
-# PRE: update
-#
-
# Regression test for double consecutive alternations
-update request {
- &Tmp-uint64-0 := "%{%{Acct-Input-Octets}:-2}%{%{Acct-Input-Gigawords}:-1}"
-}
-
+&Tmp-uint64-0 := "%{%{Acct-Input-Octets}:-2}%{%{Acct-Input-Gigawords}:-1}"
if (&Tmp-uint64-0 != 21) {
fail
}
-#
-# PRE: update
-#
-update request {
- &Tmp-String-1 := 'foo'
- &Tmp-String-1 += 'bar'
- &Tmp-Integer-0 := '4'
- &Tmp-Integer-0 += '8'
- &Tmp-Integer-0 += '1'
+&request += {
+ &Tmp-String-1 = 'foo'
+ &Tmp-String-1 = 'bar'
+ &Tmp-Integer-0 = '4'
+ &Tmp-Integer-0 = '8'
+ &Tmp-Integer-0 = '1'
- &Tmp-String-0 := '%{Tmp-String-1}'
+ &Tmp-String-0 = '%{Tmp-String-1}'
}
#
-update control {
- &Tmp-String-0 = "foo"
-}
-
-update control {
- &Tmp-String-1 := `/bin/echo hello 1234:%{control.Tmp-String-0} world`
-}
+&Tmp-String-0 = "foo"
+&Tmp-String-1 := `/bin/echo hello 1234:%{Tmp-String-0} world`
-if (&control.Tmp-String-1 != "hello 1234:foo world") {
+if (&Tmp-String-1 != "hello 1234:foo world") {
test_fail
}
-update control {
- &Tmp-String-1 := `/bin/echo hello %{control.Tmp-String-0}:1234 world`
-}
-
-if (&control.Tmp-String-1 != "hello foo:1234 world") {
+&Tmp-String-1 := `/bin/echo hello %{Tmp-String-0}:1234 world`
+if (&Tmp-String-1 != "hello foo:1234 world") {
test_fail
}
# User-Password contains characters that need escaping
-update control {
- &Tmp-String-2 := `/bin/echo %{User-Password}`
-}
-
-if (&control.Tmp-String-2 != &User-Password) {
+&Tmp-String-2 := `/bin/echo %{User-Password}`
+if (&Tmp-String-2 != &User-Password) {
test_fail
} else {
- update request {
- &User-Password := "hello"
- }
+ &User-Password := "hello"
}
success
#
-# PRE: update concat
+# PRE: concat
#
# Check explode works correctly
#
-update {
- &request.Class := '1=1|my_attr=2|my_attr=hello|'
- &request.Calling-Station-ID += '|'
- &control.User-Name += '|hello|goodbye'
- &control.User-Name += '|morning|night|1|'
- &control.Reply-Message := 'Can\'t touch this'
- &control.Tmp-String-0 := 'here. are . some. words. '
-}
-
-update {
- &request.Tmp-String-1 := "%(concat:%(explode:%{Class} |) ,)"
- &request.Tmp-String-2 := "%(concat:%(explode:%{Calling-Station-ID} |) ,)"
- &request.Tmp-String-3 := "%(concat:%(explode:%{control.User-Name[*]} |) ,)"
- &request.Tmp-String-4 := "%(concat:%(explode:%{control.Reply-Message} |) ,)"
- &request.Tmp-String-5 := "%(concat:%(explode:%{control.Tmp-String-0} '. ') ,)"
+&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'
+ &Tmp-String-0 = 'here. are . some. words. '
+}
+
+&request += {
+ &Tmp-String-1 = "%(concat:%(explode:%{Class} |) ,)"
+ &Tmp-String-2 = "%(concat:%(explode:%{Calling-Station-ID} |) ,)"
+ &Tmp-String-3 = "%(concat:%(explode:%{control.User-Name[*]} |) ,)"
+ &Tmp-String-4 = "%(concat:%(explode:%{control.Reply-Message} |) ,)"
+ &Tmp-String-5 = "%(concat:%(explode:%{control.Tmp-String-0} '. ') ,)"
}
debug_all
-#
-# PRE: update
-#
-
# Set debug to something high, recording the old level
-update request {
- &Tmp-Integer-0 := "%(debug:4)"
-}
+&Tmp-Integer-0 := "%(debug:4)"
# Check debug level is now 4
if ("%(debug:4)" != 4) {
-#
-# PRE: update
-#
-update request {
- &Tmp-String-0 := '9870'
- &Tmp-String-1 := '98709870'
- &Tmp-String-2 := '184467440737095516157'
- &Tmp-Octets-0 := 0x39383731
- &Tmp-Octets-1 := 0x3938373139383731
- &Tmp-Octets-2 := 0x393837313938373139383731
- &Tmp-IP-Address-0 := 57.56.55.50
- &Tmp-Date-0 := 959985459
- &Tmp-Integer-0 := 959985460
- &Tmp-Cast-IfId := '0000:0000:3938:3737'
- &Tmp-Cast-IPv6Addr := '::3938:3738'
- &Tmp-Cast-IPv6Prefix := '::3938:3739/128'
- &Tmp-Cast-Byte := 58
- &Tmp-Cast-Short := 14139
- &Tmp-Cast-Ether := 00:00:39:38:37:3c
- &Tmp-Cast-Integer64 := 1152921505566832445
- &Tmp-Cast-IPv4Prefix := 57.56.55.62/32
+&request += {
+ &Tmp-String-0 = '9870'
+ &Tmp-String-1 = '98709870'
+ &Tmp-String-2 = '184467440737095516157'
+ &Tmp-Octets-0 = 0x39383731
+ &Tmp-Octets-1 = 0x3938373139383731
+ &Tmp-Octets-2 = 0x393837313938373139383731
+ &Tmp-IP-Address-0 = 57.56.55.50
+ &Tmp-Date-0 = 959985459
+ &Tmp-Integer-0 = 959985460
+ &Tmp-Cast-IfId = '0000:0000:3938:3737'
+ &Tmp-Cast-IPv6Addr = '::3938:3738'
+ &Tmp-Cast-IPv6Prefix = '::3938:3739/128'
+ &Tmp-Cast-Byte = 58
+ &Tmp-Cast-Short = 14139
+ &Tmp-Cast-Ether = 00:00:39:38:37:3c
+ &Tmp-Cast-Integer64 = 1152921505566832445
+ &Tmp-Cast-IPv4Prefix = 57.56.55.62/32
}
# String - network order representation of a 4 char string
-update request {
- &Tmp-Integer-1 := "%(integer:%{Tmp-String-0})"
-}
-if ((<integer>&Tmp-String-0 != &Tmp-Integer-1) || (&Tmp-Integer-1 != 9870)) {
+&Tmp-Integer-1 := "%(integer:%{Tmp-String-0})"
+if (((integer)&Tmp-String-0 != &Tmp-Integer-1) || (&Tmp-Integer-1 != 9870)) {
test_fail
}
# String - network order representation of a 8 char string
-update request {
- &Tmp-uint64-0 := "%(integer:%{Tmp-String-1})"
-}
-if ((<integer64>&Tmp-String-1 != &Tmp-uint64-0) || (&Tmp-uint64-0 != 98709870)) {
+&Tmp-uint64-0 := "%(integer:%{Tmp-String-1})"
+if (((integer64) &Tmp-String-1 != &Tmp-uint64-0) || (&Tmp-uint64-0 != 98709870)) {
test_fail
}
}
# Octets - network order representation of a 4 byte octet string
-update request {
- &Tmp-Integer-1 := "%(integer:%{Tmp-Octets-0})"
+&Tmp-Integer-1 := "%(integer:%{Tmp-Octets-0})"
+
+if (&Tmp-Octets-0 != "%{hex:Tmp-Integer-1}") {
+ test_fail
}
-#
-# Disabled until xlats can return binary data
-#
-#if (&Tmp-Octets-0 != "%{hex:Tmp-Integer-1}") {
-# test_fail
-#}
if (&Tmp-Integer-1 != 959985457) {
test_fail
}
# Octets - network order representation of a 8 byte octet string
-update request {
- &Tmp-uint64-0 := "%(integer:%{Tmp-Octets-1})"
-}
+&Tmp-uint64-0 := "%(integer:%{Tmp-Octets-1})"
#
# Disabled until xlats can return binary data
#
-#if (&Tmp-Octets-1 != "%{hex:Tmp-uint64-0}") {
-# test_fail
-#}
+if (&Tmp-Octets-1 != "%{hex:Tmp-uint64-0}") {
+ test_fail
+}
if (&Tmp-uint64-0 != 4123106143410599729) {
test_fail
test_fail
}
-update request {
- &Tmp-String-2 := "%(integer:%{Tmp-IP-Address-0})"
- &Tmp-String-3 := "%(integer:%{Tmp-Date-0})"
- &Tmp-String-4 := "%(integer:%{Tmp-Integer-0})"
- &Tmp-String-6 := "%(integer:%{Tmp-Cast-Ifid})"
- &Tmp-String-7 := "%(integer:%{Tmp-Cast-IPv6Addr})"
- &Tmp-String-8 := "%(integer:%{Tmp-Cast-IPv6Prefix})"
-}
+&Tmp-String-2 := "%(integer:%{Tmp-IP-Address-0})"
+&Tmp-String-3 := "%(integer:%{Tmp-Date-0})"
+&Tmp-String-4 := "%(integer:%{Tmp-Integer-0})"
+&Tmp-String-6 := "%(integer:%{Tmp-Cast-Ifid})"
+&Tmp-String-7 := "%(integer:%{Tmp-Cast-IPv6Addr})"
+&Tmp-String-8 := "%(integer:%{Tmp-Cast-IPv6Prefix})"
# IP Address
if (&Tmp-String-2 != '959985458') {
test_fail
}
-if (<ipaddr>&Tmp-String-2 != &Tmp-IP-Address-0) {
+if ((ipaddr)&Tmp-String-2 != &Tmp-IP-Address-0) {
test_fail
}
if (&Tmp-String-8 != '959985465') {
test_fail
}
-update request {
- &Tmp-String-0 := "%(integer:%{Tmp-Cast-Byte})"
- &Tmp-String-1 := "%(integer:%{Tmp-Cast-Short})"
- &Tmp-uint64-2 := "%(integer:%{Tmp-Cast-Ether})"
- &Tmp-String-3 := "%(integer:%{Tmp-Cast-Integer64})"
- &Tmp-String-4 := "%(integer:%{Tmp-Cast-IPv4Prefix})"
-}
+
+&Tmp-String-0 := "%(integer:%{Tmp-Cast-Byte})"
+&Tmp-String-1 := "%(integer:%{Tmp-Cast-Short})"
+&Tmp-uint64-2 := "%(integer:%{Tmp-Cast-Ether})"
+&Tmp-String-3 := "%(integer:%{Tmp-Cast-Integer64})"
+&Tmp-String-4 := "%(integer:%{Tmp-Cast-IPv4Prefix})"
# byte
if (&Tmp-String-0 != '58') {
# with the lowest octet of the integer mapping to the right-most
# ethernet octet (in network order)
#
-if (<ether>&Tmp-uint64-2 != &Tmp-Cast-Ether) {
+if ((ether)&Tmp-uint64-2 != &Tmp-Cast-Ether) {
test_fail
}
test_fail
}
-update request {
- &Service-Type := Login-User
-}
-
-update request {
- &Tmp-Integer-2 := "%(integer:%{Service-Type})"
-}
-
+&Service-Type := Login-User
+&Tmp-Integer-2 := "%(integer:%{Service-Type})"
if (&Tmp-Integer-2 != 1) {
test_fail
}
#
-# PRE: update if
+# PRE: if
#
# Note the test for %(interpreter:.line) is sensitive to the position of the
-# "update request" line in the file
+# instruction we're running.
#
-update request {
- &Tmp-String-0 := "%(interpreter:.filename)"
- &Tmp-Integer-0 := "%(interpreter:.line)"
- &Tmp-String-1 := "%(interpreter:.name)"
- &Tmp-String-2 := "%(interpreter:.type)"
-}
+&Tmp-String-0 := "%(interpreter:.filename)"
+&Tmp-Integer-0 := "%(interpreter:.line)"
+&Tmp-String-1 := "%(interpreter:.name)"
+&Tmp-String-2 := "%(interpreter:.type)"
if (&Tmp-String-0 != "src/tests/keywords/xlat-interpreter") {
test_fail
}
-if (&Tmp-String-1 != "request") {
+if (&Tmp-String-1 != "&Tmp-String-1") {
test_fail
}
-if (&Tmp-String-2 != "update") {
+if (&Tmp-String-2 != "edit") {
test_fail
}
-if (&Tmp-Integer-0 != 8) {
+if (&Tmp-Integer-0 != 9) {
test_fail
}
-#
-# PRE: update
-#
-update {
- &control !* ANY
-}
-
-update control {
- &Tmp-IP-Address-0 := 192.0.2.1
- &Tmp-IP-Address-0 += 192.0.2.2
+&control := {
+ &Tmp-IP-Address-0 = 192.0.2.1
+ &Tmp-IP-Address-0 = 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.
-update request {
- &Tmp-IP-Address-1 += "%{control[1]}"
- &Tmp-IP-Address-1 += "%{control[0]}"
- &Tmp-String-0 = "%(concat:%{control[*]} ,)"
+&request += {
+ &Tmp-IP-Address-1 = "%{control[1]}"
+ &Tmp-IP-Address-1 = "%{control[0]}"
+ &Tmp-String-0 = "%(concat:%{control[*]} ,)"
&Tmp-Integer-0 = "%{control[#]}"
}
#
-# PRE: update if
+# PRE: if
#
# Regression test for 0x prefix. xlat expanded
# octet strings must NOT have a 0x prefix added
#
-update request {
- &Tmp-Octets-0 := 0x0001020304050607
- &Tmp-Octets-0 += 0x0706050403020100
+&request += {
+ &Tmp-Octets-0 = 0x0001020304050607
+ &Tmp-Octets-0 = 0x0706050403020100
}
if ("%{Tmp-Octets-0}" != '0x0001020304050607') {
# PRE: update
#
-update control {
- &Tmp-String-0 := %(soh:OS)
-}
+&Tmp-String-0 := %(soh:OS)
# SoH-Supported not set - should be no response
-if ("%{control.Tmp-String-0}" != "") {
+if ("%{Tmp-String-0}" != "") {
test_fail
}
-update request {
- &SoH-Supported := yes
- &SoH-MS-Machine-OS-release := 0
- &SoH-MS-Machine-OS-build := 6001
- &SoH-MS-Machine-SP-version := 1
- &SoH-MS-Machine-SP-release := 0
-}
-
-update control {
- &Tmp-String-0 := %(soh:OS)
+#
+# @todo - move these into TLVs / structs / their own protocol?
+#
+&request += {
+ &SoH-Supported = yes
+ &SoH-MS-Machine-OS-release = 0
+ &SoH-MS-Machine-OS-build = 6001
+ &SoH-MS-Machine-SP-version = 1
+ &SoH-MS-Machine-SP-release = 0
}
+&Tmp-String-0 := %(soh:OS)
# SoH-MS-Machine-OS-vendor not set - should be no response
-if ("%{control.Tmp-String-0}" != "") {
+if ("%{Tmp-String-0}" != "") {
test_fail
}
-update request {
- &SoH-Supported := yes
- &SoH-MS-Machine-OS-vendor := Microsoft
-}
-
-update control {
- &Tmp-String-0 := %(soh:OS)
-}
+&SoH-Supported := yes
+&SoH-MS-Machine-OS-vendor := Microsoft
+&Tmp-String-0 := %(soh:OS)
# OS version not set
-if ("%{control.Tmp-String-0}" != "Windows unknown") {
+if ("%{Tmp-String-0}" != "Windows unknown") {
test_fail
}
-update request {
- &SoH-MS-Machine-OS-version := 6
-}
-
-update control {
- &Tmp-String-0 := %(soh:OS)
-}
+&SoH-MS-Machine-OS-version := 6
+&Tmp-String-0 := %(soh:OS)
# Complete set of data should match a real version of Windows
-if ("%{control.Tmp-String-0}" != "Windows Vista / Server 2008 6.0.6001 sp 1.0" ) {
+if ("%{Tmp-String-0}" != "Windows Vista / Server 2008 6.0.6001 sp 1.0" ) {
test_fail
}
-update request {
- &SoH-MS-Machine-OS-release := 5
-}
-
-update control {
- &Tmp-String-0 := %(soh:OS)
-}
+&SoH-MS-Machine-OS-release := 5
+&Tmp-String-0 := %(soh:OS)
# Version and Release combination that does not exist
-if ("%{control.Tmp-String-0}" != "Windows Other 6.5.6001 sp 1.0") {
+if ("%{Tmp-String-0}" != "Windows Other 6.5.6001 sp 1.0") {
test_fail
}
-update request {
- &SoH-MS-Machine-OS-version := 8
- &SoH-MS-Machine-OS-release := 0
-}
-
-update control {
- &Tmp-String-0 := %(soh:OS)
-}
+&SoH-MS-Machine-OS-version := 8
+&SoH-MS-Machine-OS-release := 0
+&Tmp-String-0 := %(soh:OS)
# Version that does not exist
-if ("%{control.Tmp-String-0}" != "Windows Other 8.0.6001 sp 1.0") {
+if ("%{Tmp-String-0}" != "Windows Other 8.0.6001 sp 1.0") {
test_fail
}
-debug_control
success
#
-# PRE: update if
+# PRE: if
#
&request += {
&Tmp-Octets-0 = 0x5c5c
# like every other data type. If we want to *convert* the octets to
# a string, we have to use "%{string:...}"
#
-if (<string>&Tmp-Octets-0 != "0x5c5c") {
+if ((string)&Tmp-Octets-0 != "0x5c5c") {
test_fail
}
#
# And the printed "0x5c5c" is not equivalent to the octet string
#
-if (<string>&Tmp-Octets-0 == 0x5c5c) {
+if ((string)&Tmp-Octets-0 == 0x5c5c) {
test_fail
}
#
# These are now defined to be different.
#
-if (<string>&Tmp-Octets-0 == "%{string:%{Tmp-Octets-0}}") {
+if ((string)&Tmp-Octets-0 == "%{string:%{Tmp-Octets-0}}") {
test_fail
}
-#
-# PRE: update
-#
-update request {
- &Tmp-String-0 := 'aaa'
- &Tmp-String-1 := "\n\n\n"
- &Tmp-String-2 := "the quick brown fox jumped over the lazy dog"
-}
+&Tmp-String-0 := 'aaa'
+&Tmp-String-1 := "\n\n\n"
+&Tmp-String-2 := "the quick brown fox jumped over the lazy dog"
#
# Non-regex base substitutions
test_fail
}
-update request {
- &Module-Failure-Message !* ANY
-}
+&request -= &Module-Failure-Message[*]
# Empty regex
if ("%(subst:%{Tmp-String-0} //g .)") {
# We should allow the user to overload virtual attributes
-update request {
- &Client-Shortname := 'my_test_client'
-}
-
+&Client-Shortname := 'my_test_client'
if ("%{Client-Shortname}" != 'my_test_client') {
test_fail
}