-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for mixing foreaches and regexes
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# PRE: foreach if-regex-match | ||
|
||
# This is what most people end up using foreach for, | ||
# so we should probably test it works. | ||
update request { | ||
Tmp-String-0 := "cisco" | ||
} | ||
|
||
foreach Cisco-AVPair { | ||
if ("%{Foreach-Variable-0}" =~ /^%{Tmp-String-0}=(.*)$/i) { | ||
update reply { | ||
Called-Station-Id += "%{1}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Input packet | ||
# | ||
User-Name = "bob" | ||
User-Password = "hello" | ||
Cisco-AVPair = "stupid=1" | ||
Cisco-AVPair += "retarded=2" | ||
Cisco-AVPair += "cisco=3" | ||
Cisco-AVPair += "shit=4" | ||
|
||
# | ||
# Expected answer | ||
# | ||
Response-Packet-Type == Access-Accept | ||
Called-Station-Id == "3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
# PRE: if | ||
# | ||
# May as well exercise the regular expression engine | ||
# May as well exercise the regular expression engine | ||
if (User-Name !~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) { | ||
reject | ||
} | ||
|
||
if ("%{User-Name}" !~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) { | ||
reject | ||
} | ||
|
||
if (User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) { | ||
update { | ||
reply:User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}" | ||
} | ||
} | ||
|