#
# @todo - fix this...
#
-&control.Tmp-String-1 := "%(concat:%(join:%{control.[*]} %{request.Tmp-IP-Address-0}) '. ')"
+&control.Tmp-String-1 := %concat(%join(%{control.[*]}, %{request.Tmp-IP-Address-0}), '. ')
if (!(&control.Tmp-String-1 == "bob. hello. ab c. de fg. 123. 192.168.1.254")) {
test_fail
}
-&control.Tmp-String-2 := "%(concat:%(join:%{control.Tmp-String-0[*]} %{control.Tmp-Integer-0}) ,)"
+&control.Tmp-String-2 := %concat(%join(%{control.Tmp-String-0[*]}, %{control.Tmp-Integer-0}), ',')
if (!(&control.Tmp-String-2 == "ab c,de fg,123")) {
test_fail
}
#
# rpad tests
#
-if (!(%(rpad:%{Tmp-String-0} 7) == "test ")) {
+if (!(%rpad(%{Tmp-String-0}, 7) == "test ")) {
test_fail
}
-if (!(%(rpad:%{Tmp-String-0} 2) == "test")) {
+if (!(%rpad(%{Tmp-String-0}, 2) == "test")) {
test_fail
}
-if (!(%(rpad:%{Tmp-String-0} 7 x) == "testxxx")) {
+if (!(%rpad(%{Tmp-String-0}, 7, 'x') == "testxxx")) {
test_fail
}
-if (!(%(rpad:%{Tmp-String-0} 7 xy) == "testxyx")) {
+if (!(%rpad(%{Tmp-String-0}, 7, 'xy') == "testxyx")) {
test_fail
}
#
# lpad tests
#
-if (!(%(lpad:%{Tmp-String-0} 7) == " test")) {
+if (!(%lpad(%{Tmp-String-0}, 7) == " test")) {
test_fail
}
-if (!(%(lpad:%{Tmp-String-0} 2) == "test")) {
+if (!(%lpad(%{Tmp-String-0}, 2) == "test")) {
test_fail
}
-if (!(%(lpad:%{Tmp-String-0} 7 x) == "xxxtest")) {
+if (!(%lpad(%{Tmp-String-0}, 7, 'x') == "xxxtest")) {
test_fail
}
-if (!(%(lpad:%{Tmp-String-0} 7 xy) == "xyxtest")) {
+if (!(%lpad(%{Tmp-String-0}, 7, 'xy') == "xyxtest")) {
test_fail
}
}
&request += {
- &Tmp-String-1 = "%(concat:%(pairs:Tmp-Group-0.[*]) ', ')"
- &Tmp-String-2 = "%(pairs:Tmp-Group-0.Tmp-String-0)"
- &Tmp-String-3 = "%(concat:%(pairs:Tmp-Group-0.Tmp-String-0[*]) ', ')"
- &Tmp-String-4 = "%(concat:%(pairs:control.[*]) ', ')"
- &Tmp-String-5 = "%(pairs:control.User-Name)"
- &Tmp-String-6 = "%(pairs:request.Tmp-Group-0)"
+ &Tmp-String-1 = "%concat(%pairs(Tmp-Group-0.[*]), ', ')"
+ &Tmp-String-2 = "%pairs(Tmp-Group-0.Tmp-String-0)"
+ &Tmp-String-3 = "%concat(%pairs(Tmp-Group-0.Tmp-String-0[*]), ', ')"
+ &Tmp-String-4 = "%concat(%pairs(control.[*]), ', ')"
+ &Tmp-String-5 = "%pairs(control.User-Name)"
+ &Tmp-String-6 = "%pairs(request.Tmp-Group-0)"
}
if !(&Tmp-String-1 == 'Tmp-String-0 = "This is a string", Tmp-String-0 = "This is another one", Tmp-Octets-0 = 0x000504030201, Tmp-Integer-0 = 7331') {
accept
success
if(&User-Name == 'bob') {
- "%(debug:%debug(0))" # Noop
+ %debug(%debug(0)) # Noop
return
}
test_fail
# Cancel in subrequest
subrequest Access-Request {
- %(cancel:)
+ %cancel()
test_fail
}
# Cancel in nested subrequest
subrequest Access-Request {
subrequest Access-Request {
- %(cancel:)
+ %cancel()
test_fail
}
}
# Cancel parent with active subrequest, will run on next timer service
%cancel(100ms)
subrequest Access-Request {
- %(delay_10s:1s)
+ %delay_10s(1s)
}
test_fail
detach
# Smoke test for cancelling detached requests
- %(cancel:)
+ %cancel()
}
success
&Framed-IP-Address := 127.0.0.1
&Tmp-Octets-0 := &Framed-IP-Address
-&Tmp-String-0 := "%(unpack:%{Tmp-Octets-0} 0 ipaddr)"
-&Tmp-IP-Address-0 := "%(unpack:%{Tmp-Octets-0} 0 ipaddr)"
+&Tmp-String-0 := "%unpack(%{Tmp-Octets-0}, 0, 'ipaddr')"
+&Tmp-IP-Address-0 := "%unpack(%{Tmp-Octets-0}, 0, 'ipaddr')"
if !(&Tmp-String-0 == "127.0.0.1") {
test_fail
}
&Tmp-Octets-0 := 0x000001020304
-&Tmp-Integer-0 := "%(unpack:%{Tmp-Octets-0} 4 uint16)"
+&Tmp-Integer-0 := "%unpack(%{Tmp-Octets-0}, 4, 'uint16')"
# Octets 4 and 5 == 0x0304 == 772
if ~(&Tmp-Integer-0 == 772) {
# truncation
&Tmp-String-0 := "0x0011223344556677"
-&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 ether)"
+&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'ether')"
if !(&Tmp-String-1 == "00:11:22:33:44:55") {
test_fail
}
&Tmp-String-0 := "0x48656C6C6F"
-&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 string)"
+&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')"
if !(&Tmp-String-1 == "Hello") {
test_fail
}
# Offset beyond data length
&request -= &Tmp-String-1[*]
-&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 10 string)"
+&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 10, 'string')"
if !(&Tmp-String-1 == "") {
test_fail
&request -= &Module-Failure-Message[*]
# Invalid destination data type
-&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 thing)"
+&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'thing')"
if !(&Tmp-String-1 == "") {
test_fail
}
}
# Invalid source data type
-&Tmp-String-1 := "%(unpack:%{Tmp-Integer-0} 0 string)"
+&Tmp-String-1 := "%unpack(%{Tmp-Integer-0}, 0, 'string')"
if !(&Tmp-String-1 == "") {
test_fail
}
# Invalid hex string
&Tmp-String-0 := '0x014sdgw'
-&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 string)"
+&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')"
if !(&Tmp-String-1 == "") {
test_fail
# Zero length hex string
&Tmp-String-0 := '0x'
-&Tmp-String-1 := "%(unpack:%{Tmp-String-0} 0 string)"
+&Tmp-String-1 := "%unpack(%{Tmp-String-0}, 0, 'string')"
if !(&Tmp-String-1 == "") {
test_fail
&request += {
&Tmp-IP-Address-1 = &Tmp-IP-Address-0[1]
&Tmp-IP-Address-1 = &Tmp-IP-Address-0[0]
- &Tmp-String-0 = "%(concat:%{Tmp-IP-Address-0[*]} ,)"
+ &Tmp-String-0 = "%concat(%{Tmp-IP-Address-0[*]}, ',')"
&Tmp-Integer-0 = %{Tmp-IP-Address-0[#]}
}
}
&Tmp-String-0 := "test"
-&Tmp-Integer-0 := "%(config:modules.%{Tmp-String-0}.integer)"
+&Tmp-Integer-0 := %config(modules.%{Tmp-String-0}.integer)
if (!(&Tmp-Integer-0 == 1)) {
test_fail
}
#
# Check yielding works
#
-if ((time_delta)"%(reschedule:)" > 1s) {
+if ((time_delta)%reschedule() > 1s) {
test_fail
}
}
&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} '. ') ,)"
+ &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
&request += {
&Tmp-IP-Address-1 = %{control.[1]}
&Tmp-IP-Address-1 = %{control.[0]}
- &Tmp-String-0 = %(concat:%{control.[*]} ,)
+ &Tmp-String-0 = %concat(%{control.[*]}, ',')
&Tmp-Integer-0 = %{control.[#]}
}
#
# PRE: if
#
-if (!(%(concat:%(test1.passthrough:foo bar) '|') == "foo|bar")) {
+if (!(%concat(%(test1.passthrough:foo bar),'|') == "foo|bar")) {
test_fail
}
-if (!(%(concat:%(test2.passthrough:foo bar) '|') == "foo|bar")) {
+if (!(%concat(%(test2.passthrough:foo bar), '|') == "foo|bar")) {
test_fail
}
#
# The config has a "redundant" block for test1 and test2.
#
-if (!(%(concat:%(redundant_test:foo bar) '|') == "foo|bar")) {
+if (!(%concat(%(redundant_test:foo bar), '|') == "foo|bar")) {
test_fail
}
#
# Global substitution
-if (!(%(subst:%{Tmp-String-0} a b) == 'bbb')) {
+if (!(%subst(%{Tmp-String-0}, 'a', 'b') == 'bbb')) {
test_fail
}
# No match
-if (!(%(subst:%{Tmp-String-0} c b) == 'aaa')) {
+if (!(%subst(%{Tmp-String-0}, 'c', 'b') == 'aaa')) {
test_fail
}
# Line ending rewrite
-if (!(%(subst:%{Tmp-String-1} \n \r) == "\r\r\r")) {
+if (!(%subst(%{Tmp-String-1}, "\n", "\r") == "\r\r\r")) {
test_fail
}
# Removal
-if (!(%(subst:%{Tmp-String-0} a '') == "")) {
+if (!(%subst(%{Tmp-String-0}, 'a', '') == "")) {
test_fail
}
# Removal of last word only
-if (!(%(subst:%{Tmp-String-2} dog '') == "the quick brown fox jumped over the lazy ")) {
+if (!(%subst(%{Tmp-String-2}, 'dog', '') == "the quick brown fox jumped over the lazy ")) {
test_fail
}
# Removal of first and subsequent word
-if (!(%(subst:%{Tmp-String-2} the '') == " quick brown fox jumped over lazy dog")) {
+if (!(%subst(%{Tmp-String-2}, 'the', '') == " quick brown fox jumped over lazy dog")) {
test_fail
}
# Removal of middle word
-if (!(%(subst:%{Tmp-String-2} jumped '') == "the quick brown fox over the lazy dog")) {
+if (!(%subst(%{Tmp-String-2}, 'jumped', '') == "the quick brown fox over the lazy dog")) {
test_fail
}
# Replacement of last word only
-if (!(%(subst:%{Tmp-String-2} dog cat) == "the quick brown fox jumped over the lazy cat")) {
+if (!(%subst(%{Tmp-String-2}, 'dog', 'cat') == "the quick brown fox jumped over the lazy cat")) {
test_fail
}
# Replacement of first and subsequent word
-if (!(%(subst:%{Tmp-String-2} the cat) == "cat quick brown fox jumped over cat lazy dog")) {
+if (!(%subst(%{Tmp-String-2}, 'the', 'cat') == "cat quick brown fox jumped over cat lazy dog")) {
test_fail
}
# Replacement of middle word
-if (!(%(subst:%{Tmp-String-2} jumped cat) == "the quick brown fox cat over the lazy dog")) {
+if (!(%subst(%{Tmp-String-2}, 'jumped', 'cat') == "the quick brown fox cat over the lazy dog")) {
test_fail
}
if ("${feature.regex-pcre2}" == 'yes') {
# Basic substitutions
-if (!(%(subst:%{Tmp-String-0} /a/ b) == 'baa')) {
+if (!(%subst(%{Tmp-String-0}, /a/, 'b') == 'baa')) {
test_fail
}
# Global substitution
-if (!(%(subst:%{Tmp-String-0} /a/g b) == 'bbb')) {
+if (!(%subst(%{Tmp-String-0}, /a/g, 'b') == 'bbb')) {
test_fail
}
# No match
-if (!(%(subst:%{Tmp-String-0} /z/ b) == 'aaa')) {
+if (!(%subst(%{Tmp-String-0}, /z/, 'b') == 'aaa')) {
test_fail
}
#
# Check that newlines really are newlines
-if (!("%length(%{Tmp-String-1})" == 3)) {
+if (!(%length(%{Tmp-String-1}) == 3)) {
test_fail
}
# Strip out just the first newline
-if (!(%(subst:%{Tmp-String-1} /^./s '') == "\n\n")) {
+if (!(%subst(%{Tmp-String-1}, /^./s, '') == "\n\n")) {
test_fail
}
-if (!(%(subst:%{Tmp-String-1} /\n/ '') == "\n\n")) {
+if (!(%subst(%{Tmp-String-1}, /\n/, '') == "\n\n")) {
test_fail
}
# Strip out all the newlines
-if (!(%(subst:%{Tmp-String-1} /\n/g '') == '')) {
+if (!(%subst(%{Tmp-String-1}, /\n/g, '') == '')) {
test_fail
}
# Line ending switch
-if (!(%(subst:%{Tmp-String-1} /\n/g \r) == "\r\r\r")) {
+if (!(%subst(%{Tmp-String-1}, /\n/g, "\r") == "\r\r\r")) {
test_fail
}
# Bad regex
-if ("%(subst:%{Tmp-String-0} /***/g .)") {
+if (%subst(%{Tmp-String-0}, /***/g, '.')) {
test_fail
}
&request -= &Module-Failure-Message[*]
# Empty regex
-if ("%(subst:%{Tmp-String-0} //g .)") {
+if (%subst(%{Tmp-String-0}, //g, '.')) {
test_fail
}