diff options
Diffstat (limited to '')
-rw-r--r-- | src/tests/keywords/foreach-break | 73 | ||||
-rw-r--r-- | src/tests/keywords/foreach-break-2 | 46 | ||||
-rw-r--r-- | src/tests/keywords/foreach-break-3 | 44 | ||||
-rw-r--r-- | src/tests/keywords/foreach-break-4 | 44 | ||||
-rw-r--r-- | src/tests/keywords/foreach-break.attrs | 18 |
5 files changed, 225 insertions, 0 deletions
diff --git a/src/tests/keywords/foreach-break b/src/tests/keywords/foreach-break new file mode 100644 index 0000000..67812fe --- /dev/null +++ b/src/tests/keywords/foreach-break @@ -0,0 +1,73 @@ +# PRE: foreach +# + +# +# We DON'T want to see this one. +# +update request { + Filter-Id += "broken" +} + +foreach Filter-Id { + # + # If we see this one, "break" out of the + # foreach loop. + # + if ("%{Foreach-Variable-0}" == "broken") { + break + } + + update reply { + Called-Station-Id += "%{Foreach-Variable-0}" + } +} + + +# +# Adding attribute during request and immediately breaking +# +update { + request:Filter-Id += "1" + request:Filter-Id += "2" +} + +foreach &request:Reply-Message { + if("%{Foreach-Variable-0}" == "1") { + update { + request:Filter-Id += "3" + } + break + + update reply { + Filter-Id := "fail-break-1" + } + } +} + +update { + request:Filter-Id !* ANY +} + +# +# Adding attribute during request and continuing +# +update { + request:Filter-Id += "1" + request:Filter-Id += "2" +} + +foreach &request:Reply-Message { + if("%{Foreach-Variable-0}" == "1") { + update { + request:Filter-Id += "3" + } + } + + if ("%{Foreach-Variable-0}" == "3") { + break + + update reply { + Filter-Id := "fail-break-2" + } + } +} diff --git a/src/tests/keywords/foreach-break-2 b/src/tests/keywords/foreach-break-2 new file mode 100644 index 0000000..b1f6040 --- /dev/null +++ b/src/tests/keywords/foreach-break-2 @@ -0,0 +1,46 @@ +# +# PRE: foreach foreach-break +# + +update request { + Calling-Station-Id := "ABCDEF_8" +} + +update control { + &Tmp-String-0 := "0" + &Tmp-String-0 += "1" + &Tmp-String-0 += "2" + &Tmp-String-0 += "3" + &Tmp-String-0 += "4" + &Tmp-String-0 += "5" + &Tmp-String-0 += "6" + &Tmp-String-0 += "7" + &Tmp-String-0 += "8" + &Tmp-String-0 += "9" + &Tmp-String-0 += "a" + &Tmp-String-0 += "b" + &Tmp-String-0 += "c" + &Tmp-String-0 += "d" + &Tmp-String-0 += "e" + &Tmp-String-0 += "f" + &Tmp-String-0 += "g" +} + +foreach control:Tmp-String-0 { + if ("%{Calling-Station-Id[*]}" =~ /([A-Z0-9\-]*)_%{Foreach-Variable-0}/) { + update request { + Called-Station-Id := "%{1}" + } + update reply { + Filter-Id := "filter" + } + + break + } + elsif ("%{Foreach-Variable-0}" == '9') { + update reply { + Filter-Id := "fail-9" + } + reject + } +} diff --git a/src/tests/keywords/foreach-break-3 b/src/tests/keywords/foreach-break-3 new file mode 100644 index 0000000..af03da6 --- /dev/null +++ b/src/tests/keywords/foreach-break-3 @@ -0,0 +1,44 @@ +# +# PRE: foreach foreach-break +# + +update request { + Calling-Station-Id := "8" +} + +update control { + &Calling-Station-Id := "0" + &Calling-Station-Id += "1" + &Calling-Station-Id += "2" + &Calling-Station-Id += "3" + &Calling-Station-Id += "4" + &Calling-Station-Id += "5" + &Calling-Station-Id += "6" + &Calling-Station-Id += "7" + &Calling-Station-Id += "8" + &Calling-Station-Id += "9" + &Calling-Station-Id += "a" + &Calling-Station-Id += "b" + &Calling-Station-Id += "c" + &Calling-Station-Id += "d" + &Calling-Station-Id += "e" + &Calling-Station-Id += "f" + &Calling-Station-Id += "g" +} + +foreach &control:Calling-Station-Id { + if (&request:Calling-Station-Id == "%{Foreach-Variable-0}") { + update reply { + Filter-Id := "filter" + } + + break + } + elsif ("%{Foreach-Variable-0}" == '9') { + update reply { + Filter-Id := "fail-9" + } + + reject + } +} diff --git a/src/tests/keywords/foreach-break-4 b/src/tests/keywords/foreach-break-4 new file mode 100644 index 0000000..037af8e --- /dev/null +++ b/src/tests/keywords/foreach-break-4 @@ -0,0 +1,44 @@ +# +# PRE: foreach foreach-break-3 +# + +update request { + Calling-Station-Id := "8" +} + +update control { + &Calling-Station-Id := "0" + &Calling-Station-Id += "1" + &Calling-Station-Id += "2" + &Calling-Station-Id += "3" + &Calling-Station-Id += "4" + &Calling-Station-Id += "5" + &Calling-Station-Id += "6" + &Calling-Station-Id += "7" + &Calling-Station-Id += "8" + &Calling-Station-Id += "9" + &Calling-Station-Id += "a" + &Calling-Station-Id += "b" + &Calling-Station-Id += "c" + &Calling-Station-Id += "d" + &Calling-Station-Id += "e" + &Calling-Station-Id += "f" + &Calling-Station-Id += "g" +} + +foreach &control:Calling-Station-Id { + if (&request:Calling-Station-Id == "%{Foreach-Variable-0}") { + update reply { + Filter-Id := "filter" + } + + break + } + elsif ("%{Foreach-Variable-0}" == '9') { + update reply { + Filter-Id := "fail-9" + } + + reject + } +} diff --git a/src/tests/keywords/foreach-break.attrs b/src/tests/keywords/foreach-break.attrs new file mode 100644 index 0000000..26c2876 --- /dev/null +++ b/src/tests/keywords/foreach-break.attrs @@ -0,0 +1,18 @@ +# +# Input packet +# +User-Name = "bob" +User-Password = "hello" +Filter-Id = "1" +Filter-Id += "2" +Filter-Id += "3" +Filter-Id += "4" + +# +# Expected answer +# +Response-Packet-Type == Access-Accept +Called-Station-Id == "1" +Called-Station-Id == "2" +Called-Station-Id == "3" +Called-Station-Id == "4" |