Debian Codegraph @

src/tests/keywords/if-regex-match-comp

raw
1 # PRE: if
2 #
3
4 # Non matching on attribute ref
5 if (User-Name !~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
6 update reply {
7 Filter-Id += 'Fail 0'
8 }
9 }
10
11 # Matching on xlat expanded value
12 if ("%{User-Name}" !~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
13 update reply {
14 Filter-Id += 'Fail 1'
15 }
16 }
17
18 # Matching on attribute ref with capture groups
19 if (User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
20 # Test all the capture groups
21 update {
22 reply:User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
23 }
24 }
25 else {
26 update reply {
27 Filter-Id += 'Fail 2'
28 }
29 }
30
31 # Checking capture groups are cleared out correctly
32 if (User-Name =~ /^([0-9])_/) {
33 if ("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" != '1_1') {
34 update reply {
35 Filter-Id += 'Fail 3'
36 }
37 }
38 }
39 else {
40 update reply {
41 Filter-Id += 'Fail 3.5'
42 }
43 }
44
45 # Checking capture groups are cleared out correctly when there are no matches
46 if (User-Name =~ /^./) {
47 if ("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" != '1') {
48 update reply {
49 Filter-Id += 'Fail 4'
50 }
51 }
52 }
53 else {
54 update reply {
55 Filter-Id += 'Fail 4.5'
56 }
57 }
58
59 # compiled - ref - insensitive
60 if (Calling-Station-Id !~ /:roamyroam$/i) {
61 update reply {
62 Filter-Id += 'Fail 5'
63 }
64 }
65
66 # compiled - expansion - insensitive
67 if ("%{Calling-Station-Id}" !~ /:roamyroam$/i) {
68 update reply {
69 Filter-Id += 'Fail 6'
70 }
71 }
72
73 # compiled - enum - ref - insensitive
74 if (Service-Type !~ /^framed-user$/i) {
75 update reply {
76 Filter-Id += 'Fail 7'
77 }
78 }
79
80 # compiled - enum - expansion - insensitive
81 if ("%{Service-Type}" !~ /^framed-user$/i) {
82 update reply {
83 Filter-Id += 'Fail 8'
84 }
85 }
86
87 # compiled - enum - ref
88 if (Service-Type =~ /^framed-user$/) {
89 update reply {
90 Filter-Id += 'Fail 9'
91 }
92 }
93
94 update request {
95 Tmp-String-0 := "foo\nbar"
96 }
97
98 # compiled - ref - multiline
99 if (&Tmp-String-0 !~ /^foo$/m) {
100 update reply {
101 Filter-Id += 'Fail 14'
102 }
103 }
104
105 # compiled - ref - non-multiline
106 if (&Tmp-String-0 =~ /^foo$/) {
107 update reply {
108 Filter-Id += 'Fail 15'
109 }
110 }
111
112 # compiled - ref - non-multiline
113
114 # Not all POSIX implementations support the \n character classes
115 # so only run this test if the server was built with libpcre.
116 if (("${feature.regex-pcre}" == 'yes') && (&Tmp-String-0 !~ /^foo\nbar$/)) {
117 update reply {
118 Filter-Id += 'Fail 16'
119 }
120 }
121
122 # compiled - ref - multiline
123 if (&Tmp-String-0 !~ /^bar$/m) {
124 update reply {
125 Filter-Id += 'Fail 17'
126 }
127 }
128
129 # compiled - ref - multiline - sensitive
130 if (&Tmp-String-0 =~ /^BAR$/m) {
131 update reply {
132 Filter-Id += 'Fail 17'
133 }
134 }
135
136 # compiled - ref - multiline - insensitive
137 if (&Tmp-String-0 !~ /^BAR$/mi) {
138 update reply {
139 Filter-Id += 'Fail 17'
140 }
141 }
142
143 # compiled - ref - multiline - insensitive (flag order reversed)
144 if (&Tmp-String-0 !~ /^BAR$/im) {
145 update reply {
146 Filter-Id += 'Fail 18'
147 }
148 }
149