Debian Codegraph @

src/tests/keywords/if-regex-match

raw
1 # PRE: if
2 #
3 update request {
4 Tmp-Integer-0 := '123456789'
5 }
6
7 # Non matching on attribute ref
8 if (User-Name !~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{Tmp-String-0}/) {
9 update reply {
10 Filter-Id += 'Fail 0'
11 }
12 }
13
14 # Matching on xlat expanded value
15 if ("%{User-Name}" !~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{Tmp-String-0}/) {
16 update reply {
17 Filter-Id += 'Fail 1'
18 }
19 }
20
21 # Matching on attribute ref with capture groups
22 if (User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{Tmp-String-0}/) {
23 # Test all the capture groups
24 update {
25 reply:User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
26 }
27 }
28 else {
29 update reply {
30 Filter-Id += 'Fail 2'
31 }
32 }
33
34 # Checking capture groups are cleared out correctly
35 if (User-Name =~ /^([0-9])_%{Tmp-String-0}/) {
36 if ("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" != '1_1') {
37 update reply {
38 Filter-Id += 'Fail 3'
39 }
40 }
41 }
42 else {
43 update reply {
44 Filter-Id += 'Fail 3.5'
45 }
46 }
47
48 # Checking capture groups are cleared out correctly when there are no matches
49 if (User-Name =~ /^.%{Tmp-String-0}/) {
50 if ("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" != '1') {
51 update reply {
52 Filter-Id += 'Fail 4'
53 }
54 }
55 }
56 else {
57 update reply {
58 Filter-Id += 'Fail 4.5'
59 }
60 }
61
62 # Checking full capture group range
63 if ('a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F' =~ /^(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)$/) {
64 if ("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}%{8}%{9}%{10}%{11}%{12}%{13}%{14}%{15}%{16}%{17}%{18}%{19}%{20}%{21}%{22}%{23}%{24}%{25}%{26}%{27}%{28}%{29}%{30}%{31}%{32}" != 'a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_FabcdefghijklmnopqrstuvwxyzABCDEF') {
65 update reply {
66 Filter-Id += 'Fail 6'
67 }
68 }
69 }
70 else {
71 update reply {
72 Filter-Id += 'Fail 6.5'
73 }
74 }
75
76 # Checking full capture group overun
77 if ('a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F_G' =~ /^(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)$/) {
78 if ("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}%{8}%{9}%{10}%{11}%{12}%{13}%{14}%{15}%{16}%{17}%{18}%{19}%{20}%{21}%{22}%{23}%{24}%{25}%{26}%{27}%{28}%{29}%{30}%{31}%{32}" != 'a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F_GabcdefghijklmnopqrstuvwxyzABCDEF') {
79 update reply {
80 Filter-Id += 'Fail 7'
81 }
82 }
83 }
84 else {
85 update reply {
86 Filter-Id += 'Fail 7.5'
87 }
88 }
89
90 # uncompiled - ref - insensitive
91 if (Calling-Station-Id !~ /:roamyroam%{Tmp-String-0}$/i) {
92 update reply {
93 Filter-Id += 'Fail 8'
94 }
95 }
96
97 # uncompiled - expansion - insensitive
98 if ("%{Calling-Station-Id}" !~ /:roamyroam%{Tmp-String-0}$/i) {
99 update reply {
100 Filter-Id += 'Fail 9'
101 }
102 }
103
104 # uncompiled - enum - ref - insensitive
105 if (Service-Type !~ /^framed-user%{Tmp-String-0}$/i) {
106 update reply {
107 Filter-Id += 'Fail 10'
108 }
109 }
110
111 # uncompiled - enum - expansion - insensitive
112 if ("%{Service-Type}" !~ /^framed-user%{Tmp-String-0}$/i) {
113 update reply {
114 Filter-Id += 'Fail 11'
115 }
116 }
117
118 # uncompiled - enum - ref
119 if (Service-Type =~ /^framed-user%{Tmp-String-0}$/) {
120 update reply {
121 Filter-Id += 'Fail 12'
122 }
123 }
124
125 # uncompiled - integer - ref
126 if (Tmp-Integer-0 !~ /%{Tmp-Integer-0}/) {
127 update reply {
128 Filter-Id += 'Fail 13'
129 }
130 }
131
132 update request {
133 Tmp-String-0 := "foo\nbar"
134 }
135
136 # uncompiled - ref - multiline
137 if (&Tmp-String-0 !~ /^foo$%{Tmp-String-8}/m) {
138 update reply {
139 Filter-Id += 'Fail 14'
140 }
141 }
142
143 # uncompiled - ref - non-multiline
144 if (&Tmp-String-0 =~ /^foo$%{Tmp-String-8}/) {
145 update reply {
146 Filter-Id += 'Fail 15'
147 }
148 }
149
150 # uncompiled - ref - non-multiline
151 if (&Tmp-String-0 !~ /^foo\nbar%{Tmp-String-8}$/) {
152 update reply {
153 Filter-Id += 'Fail 16'
154 }
155 }
156
157 # uncompiled - ref - multiline
158 if (&Tmp-String-0 !~ /^bar%{Tmp-String-8}$/m) {
159 update reply {
160 Filter-Id += 'Fail 17'
161 }
162 }
163
164 # uncompiled - ref - multiline - sensitive
165 if (&Tmp-String-0 =~ /^BAR%{Tmp-String-8}$/m) {
166 update reply {
167 Filter-Id += 'Fail 18'
168 }
169 }
170
171 # uncompiled - ref - multiline - insensitive
172 if (&Tmp-String-0 !~ /^BAR%{Tmp-String-8}$/mi) {
173 update reply {
174 Filter-Id += 'Fail 19'
175 }
176 }
177
178 # uncompiled - ref - multiline - insensitive (flag order reversed)
179 if (&Tmp-String-0 !~ /^BAR%{Tmp-String-8}$/im) {
180 update reply {
181 Filter-Id += 'Fail 20'
182 }
183 }