added basic ssl support to ircu
[ircu2.10.12-pk.git] / tests / glines.cmd
1 define srv1 localhost:7601
2 define srv1-name irc.example.net
3 define srv2 localhost:7611
4 define srv2-name irc-2.example.net
5 define cl1-nick Op3rm4n
6 define cl2-nick Monitor
7
8 # Connect a client, oper it up and force G-line server notices on (0x8200).
9 connect cl1 %cl1-nick% oper %srv1% :Some IRC Operator
10 :cl1 oper oper oper
11 :cl1 mode %cl1-nick% +s +33280
12
13 # Do the same for the second server, for monitoring snotices.
14 # This is useful while debugging the remote operations in this script.
15 connect cl2 %cl2-nick% oper %srv2% :Some IRC Operator
16 :cl2 oper oper oper
17 :cl2 mode %cl2-nick% +s +33280
18
19 # For an operator, the syntax is:
20 #  GLINE [[!][+|-|>|<]<mask> [<target>] [<expiration> [:<reason>]]]
21 # By itself, that's 2 * 5 * 3 (target missing/self, other or global)
22 #  * 3 = 90 possibilities.
23 #
24 # In each case, we would want to try it with various combinations:
25 # - Local gline for <mask> absent or present
26 # - Global gline for <mask> absent, or present but locally and/or globally activated or deactivated (5 combinations)
27 # So ten pre-existing states for each syntax variant.
28 # For sanity's sake, we don't do all 900 combinations.
29 #
30 # Perl code to generate a fairly complete list:
31 # foreach my $operator (split(//, ' +-><')) {
32 #     foreach my $mask ('test@example.com') {
33 #         foreach my $target ('', '%srv1-name%', '%srv2-name%', '*') {
34 #             foreach my $expiration ('', '100000') {
35 #                 foreach my $reason ('', ':foo') {
36 #                     my $str = "GLINE ${operator}${mask} ${target} ${expiration} ${reason}";
37 #                     $str =~ s/ +/ /g;
38 #                     $str =~ s/ +$//;
39 #                     print "$str\n";
40 #                 }
41 #             }
42 #         }
43 #         print "\n";
44 #     }
45 # }
46
47 # Initial query: verify that our target G-line does not exist.
48 :cl1 raw :GLINE test@example.com
49 :cl1 expect %srv1-name% 512 test@example.com :No such gline
50
51 # Try a bunch of operations, only one of which should generate an actual G-line.
52 :cl1 raw :GLINE test@example.com :foo
53 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
54 :cl1 raw :GLINE test@example.com 100000
55 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
56 :cl1 raw :GLINE test@example.com 100000 :foo
57 :cl1 expect %srv1-name% 515 foo :Bad expire time
58 :cl1 raw :GLINE test@example.com %srv1-name%
59 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
60 :cl1 raw :GLINE test@example.com %srv1-name% :foo
61 :cl1 expect %srv1-name% 515 foo :Bad expire time
62 :cl1 raw :GLINE test@example.com %srv1-name% 100000
63 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
64
65 # Check that we still have no G-line, and that we create it as expected.
66 :cl1 raw :GLINE test@example.com
67 :cl1 expect %srv1-name% 512 test@example.com :No such gline
68 :cl1 raw :GLINE test@example.com %srv1-name% 100000 :foo
69 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% adding local GLINE for test@example.com, expiring at \\d+: foo
70 :cl1 raw :GLINE test@example.com
71 :cl1 expect %srv1-name% 280 test@example.com \\d+ 0 \\d+ %srv1-name% \\+ :foo
72 :cl1 expect %srv1-name% 281 :End of G-line List
73 # Now remove it (and verify removal).
74 :cl1 raw :GLINE -test@example.com 100000 :foo
75 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% removing local GLINE for test@example.com
76 :cl1 raw :GLINE test@example.com
77 :cl1 expect %srv1-name% 512 test@example.com :No such gline
78
79 # Try doing remote operations.
80 :cl1 raw :GLINE test@example.com %srv2-name%
81 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
82 :cl1 raw :GLINE test@example.com %srv2-name% :foo
83 :cl1 expect %srv1-name% 515 foo :Bad expire time
84 :cl1 raw :GLINE test@example.com %srv2-name% 100000
85 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
86 :cl1 raw :GLINE test@example.com
87 :cl1 expect %srv1-name% 512 test@example.com :No such gline
88 :cl1 raw :GLINE test@example.com %srv2-name% 100000 :foo
89 # No response expected for remote commands; do a remote stats query to check.
90 :cl1 raw :STATS g %srv2-name%
91 :cl1 expect %srv2-name% 247 G test@example.com \\d+ 0 \\d+ \\+ :foo
92 :cl1 expect %srv2-name% 219 g :End of /STATS report
93 :cl1 raw :GLINE -test@example.com %srv2-name% 100000 :foo
94 :cl1 raw :STATS g %srv2-name%
95 :cl1 expect %srv2-name% 219 g :End of /STATS report
96
97 # Try doing network-wide operations.
98 :cl1 raw :GLINE test@example.com *
99 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
100 # These should fail because no existing G-line matches.
101 :cl1 raw :GLINE test@example.com * :foo
102 :cl1 expect %srv1-name% 515 foo :Bad expire time
103 :cl1 raw :GLINE test@example.com * 100000
104 :cl1 expect %srv1-name% 512 test@example.com :No such gline
105 :cl1 raw :GLINE test@example.com * 100000 :foo
106 :cl1 expect %srv1-name% 512 test@example.com :No such gline
107
108 # Try explicit create/activate operations.
109 :cl1 raw :GLINE +test@example.com
110 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
111 :cl1 raw :GLINE +test@example.com :foo
112 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
113 :cl1 raw :GLINE +test@example.com 100000
114 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
115 # This next one should create the G-line.
116 :cl1 raw :GLINE test@example.com
117 :cl1 expect %srv1-name% 512 test@example.com :No such gline
118 :cl1 raw :GLINE +test@example.com 100000 :foo
119 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% adding local GLINE for test@example.com, expiring at \\d+: foo
120 :cl1 raw :GLINE test@example.com
121 :cl1 expect %srv1-name% 280 test@example.com \\d+ 0 \\d+ %srv1-name% \\+ :foo
122 :cl1 expect %srv1-name% 281 :End of G-line List
123 :cl1 raw :GLINE -test@example.com 100000 :foo
124 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% removing local GLINE for test@example.com
125
126 # Local create/activate operations?
127 :cl1 raw :GLINE +test@example.com %srv1-name%
128 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
129 :cl1 raw :GLINE +test@example.com %srv1-name% :foo
130 :cl1 expect %srv1-name% 515 .+ :Bad expire time
131 :cl1 raw :GLINE +test@example.com %srv1-name% 100000
132 :cl1 expect %srv1-name% 515 .+ :Bad expire time
133 :cl1 raw :GLINE +test@example.com %srv1-name% 100000 :foo
134 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% adding local GLINE for test@example.com, expiring at \\d+: foo
135 :cl1 raw :GLINE test@example.com
136 :cl1 expect %srv1-name% 280 test@example.com \\d+ 0 \\d+ %srv1-name% \\+ :foo
137 :cl1 expect %srv1-name% 281 :End of G-line List
138 :cl1 raw :GLINE -test@example.com 100000 :foo
139 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% removing local GLINE for test@example.com
140 :cl1 raw :GLINE +test@example.com %srv1-name% 100000 :foo
141 :cl1 raw :GLINE -test@example.com 100000 :foo
142 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% removing local GLINE for test@example.com
143 :cl1 raw :GLINE +test@example.com %srv1-name% 100000 :foo
144 :cl1 raw :GLINE -test@example.com %srv1-name% 100000 :foo
145 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% removing local GLINE for test@example.com
146
147 # Remote create/activate operations?
148 :cl1 raw :GLINE +test@example.com %srv2-name%
149 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
150 :cl1 raw :GLINE +test@example.com %srv2-name% :foo
151 :cl1 expect %srv1-name% 515 .+ :Bad expire time
152 :cl1 raw :GLINE +test@example.com %srv2-name% 100000
153 :cl1 expect %srv1-name% 515 .+ :Bad expire time
154 :cl1 raw :GLINE +test@example.com %srv2-name% 100000 :foo
155 # No response expected for remote commands; do a remote stats query to check.
156 :cl1 raw :STATS g %srv2-name%
157 :cl1 expect %srv2-name% 247 G test@example.com \\d+ 0 \\d+ \\+ :foo
158 :cl1 expect %srv2-name% 219 g :End of /STATS report
159 :cl1 raw :GLINE -test@example.com %srv2-name% 100000 :foo
160 :cl1 raw :STATS g %srv2-name%
161 :cl1 expect %srv2-name% 219 g :End of /STATS report
162
163 # Global create/activate operations?
164 :cl1 raw :GLINE +test@example.com *
165 :cl1 expect %srv1-name% 512 test@example.com :No such gline
166 :cl1 raw :GLINE +test@example.com * :foo
167 :cl1 expect %srv1-name% 515 .+ :Bad expire time
168 :cl1 raw :GLINE +test@example.com * 100000
169 :cl1 expect %srv1-name% 515 .+ :Bad expire time
170
171 # Local G-line deactivation?
172 :cl1 raw :GLINE -test@example.com
173 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
174 :cl1 raw :GLINE -test@example.com :foo
175 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
176 :cl1 raw :GLINE -test@example.com 100000
177 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
178 :cl1 raw :GLINE -test@example.com 100000 :foo
179 :cl1 expect %srv1-name% 512 test@example.com :No such gline
180
181 # .. with a specified server?
182 :cl1 raw :GLINE -test@example.com %srv1-name%
183 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
184 :cl1 raw :GLINE -test@example.com %srv1-name% :foo
185 :cl1 expect %srv1-name% 515 %srv1-name% :Bad expire time
186 :cl1 raw :GLINE -test@example.com %srv1-name% 100000
187 :cl1 expect %srv1-name% 515 %srv1-name% :Bad expire time
188 :cl1 raw :GLINE -test@example.com %srv1-name% 100000 :foo
189 :cl1 expect %srv1-name% 512 test@example.com :No such gline
190 :cl1 raw :GLINE -test@example.com %srv2-name%
191 :cl1 expect %srv1-name% 461 GLINE :Not enough parameters
192 :cl1 raw :GLINE -test@example.com %srv2-name% :foo
193 :cl1 expect %srv1-name% 515 %srv2-name% :Bad expire time
194 :cl1 raw :GLINE -test@example.com %srv2-name% 100000
195 :cl1 expect %srv1-name% 515 %srv2-name% :Bad expire time
196 :cl1 raw :GLINE -test@example.com %srv2-name% 100000 :foo
197 :cl1 expect %srv2-name% 512 test@example.com :No such gline
198
199 # Global deactivations?
200 :cl1 raw :GLINE -test@example.com *
201 :cl1 expect %srv1-name% 512 test@example.com :No such gline
202 :cl1 raw :GLINE -test@example.com * :foo
203 :cl1 expect %srv1-name% 515 \\* :Bad expire time
204 :cl1 raw :GLINE -test@example.com * 100000
205 :cl1 expect %srv1-name% 515 \\* :Bad expire time
206 :cl1 raw :GLINE -test2@example.com * 100000 :foo
207 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% adding deactivated global GLINE for test2@example.com
208
209 # Now start with the operations that create or need a global G-line.
210
211 # Global activations and deactivations?
212 :cl1 raw :GLINE +test@example.com * 100000 :foo
213 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% adding global GLINE for test@example.com
214 :cl1 raw :GLINE test@example.com
215 :cl1 expect %srv1-name% 280 test@example.com \\d+ \\d+ \\d+ \\* \\+ :foo
216 :cl1 raw :GLINE test@example.com * 100000
217 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: changing expiration time to \\d+; and extending record lifetime to \\d+
218 :cl1 raw :GLINE test@example.com * 100000 :food
219 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: changing expiration time to \\d+; extending record lifetime to \\d+; and changing reason to "food"
220 :cl1 raw :GLINE -test@example.com *
221 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: globally deactivating G-line
222 :cl1 raw :GLINE -test@example.com * 100000 :foo
223 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: changing expiration time to \\d+; extending record lifetime to \\d+; and changing reason to "foo"
224 :cl1 raw :GLINE test@example.com
225 :cl1 expect %srv1-name% 280 test@example.com \\d+ \\d+ \\d+ \\* - :foo
226
227 # Failed local activations and deactivations?
228 :cl1 raw :GLINE >test@example.com
229 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally activating G-line
230 :cl1 raw :GLINE <test@example.com
231 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally deactivating G-line
232 :cl1 raw :GLINE >test@example.com :foo
233 :cl1 expect %srv1-name% 402 foo :No such server
234 :cl1 raw :GLINE <test@example.com :foo
235 :cl1 expect %srv1-name% 402 foo :No such server
236 :cl1 raw :GLINE >test@example.com 100000
237 :cl1 expect %srv1-name% 402 100000 :No such server
238 :cl1 raw :GLINE <test@example.com 100000 :foo
239 :cl1 expect %srv1-name% 402 100000 :No such server
240 :cl1 raw :GLINE <test@example.com 100000 :foo
241 :cl1 expect %srv1-name% 402 100000 :No such server
242 :cl1 raw :GLINE >test@2.example.com
243 :cl1 expect %srv1-name% 512 test@2.example.com :No such gline
244 :cl1 raw :GLINE >test@example.com %srv1-name%
245
246 # What about successes for the local server?
247 # (For simplicity, single-server activations and deactivations are not
248 # allowed to change any other parameters.)
249 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally activating G-line
250 :cl1 raw :GLINE <test@example.com %srv1-name%
251 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally deactivating G-line
252 :cl1 raw :GLINE >test@example.com %srv1-name% :foo
253 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally activating G-line
254 :cl1 raw :GLINE <test@example.com %srv1-name% :foo
255 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally deactivating G-line
256 :cl1 raw :GLINE >test@example.com %srv1-name% 100000
257 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally activating G-line
258 :cl1 raw :GLINE <test@example.com %srv1-name% 100000
259 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally deactivating G-line
260 :cl1 raw :GLINE >test@example.com %srv1-name% 100000 :foo
261 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally activating G-line
262 :cl1 raw :GLINE <test@example.com %srv1-name% 100000 :foo
263 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally deactivating G-line
264 :cl1 raw :GLINE >test@example.com %srv1-name% 100000 :foo
265 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally activating G-line
266 :cl1 raw :GLINE <test@example.com %srv1-name% 100000 :foo
267 :cl1 expect %srv1-name% NOTICE :\\*\\*\\* Notice -- %cl1-nick% modifying global GLINE for test@example.com: locally deactivating G-line
268
269 # And successful activations/deactiations for a (single) remote server?
270 # First make sure the global G-line is globally activated.
271 :cl1 raw :GLINE +test@example.com * 100000 :foo
272 # Form: "GLINE <gline@mask server.name"
273 :cl1 raw :STATS g %srv2-name%
274 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ \\+ :foo
275 :cl1 expect %srv2-name% 219 g :End of /STATS report
276 :cl1 raw :GLINE <test@example.com %srv2-name%
277 :cl1 raw :STATS g %srv2-name%
278 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ <\\+ :foo
279 :cl1 expect %srv2-name% 219 g :End of /STATS report
280 :cl1 raw :GLINE >test@example.com %srv2-name%
281 :cl1 raw :STATS g %srv2-name%
282 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ >\\+ :foo
283 :cl1 expect %srv2-name% 219 g :End of /STATS report
284 # Form: "GLINE <gline@mask server.name :foo"
285 :cl1 raw :GLINE <test@example.com %srv2-name% :foo
286 :cl1 raw :STATS g %srv2-name%
287 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ <\\+ :foo
288 :cl1 expect %srv2-name% 219 g :End of /STATS report
289 :cl1 raw :GLINE >test@example.com %srv2-name% :foo
290 :cl1 raw :STATS g %srv2-name%
291 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ >\\+ :foo
292 :cl1 expect %srv2-name% 219 g :End of /STATS report
293 # Form: "GLINE <gline@mask server.name 100000"
294 :cl1 raw :GLINE <test@example.com %srv2-name% 100000
295 :cl1 raw :STATS g %srv2-name%
296 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ <\\+ :foo
297 :cl1 expect %srv2-name% 219 g :End of /STATS report
298 :cl1 raw :GLINE >test@example.com %srv2-name% 100000
299 :cl1 raw :STATS g %srv2-name%
300 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ >\\+ :foo
301 :cl1 expect %srv2-name% 219 g :End of /STATS report
302 # Form: "GLINE <gline@mask server.name 100000 :foo"
303 :cl1 raw :GLINE <test@example.com %srv2-name% 100000 :foo
304 :cl1 raw :STATS g %srv2-name%
305 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ <\\+ :foo
306 :cl1 expect %srv2-name% 219 g :End of /STATS report
307 :cl1 raw :GLINE >test@example.com %srv2-name% 100000 :foo
308 :cl1 raw :STATS g %srv2-name%
309 :cl1 expect %srv2-name% 247 G test@example.com \\d+ \\d+ \\d+ >\\+ :foo
310 :cl1 expect %srv2-name% 219 g :End of /STATS report
311
312 # What about activations/deactivations that might go across the whole network?
313 # (These are not permitted because "global local [de]activation" does not
314 # make sense: just globally [de]activate the G-line.)
315 :cl1 raw :GLINE >test@example.com *
316 :cl1 expect %srv1-name% 402 \\* :No such server
317 :cl1 raw :GLINE <test@example.com *
318 :cl1 expect %srv1-name% 402 \\* :No such server
319 :cl1 raw :GLINE >test@example.com * :foo
320 :cl1 expect %srv1-name% 402 \\* :No such server
321 :cl1 raw :GLINE <test@example.com * :foo
322 :cl1 expect %srv1-name% 402 \\* :No such server
323 :cl1 raw :GLINE >test@example.com * 100000
324 :cl1 expect %srv1-name% 402 \\* :No such server
325 :cl1 raw :GLINE <test@example.com * 100000
326 :cl1 expect %srv1-name% 402 \\* :No such server
327 :cl1 raw :GLINE >test@example.com * 100000 :foo
328 :cl1 expect %srv1-name% 402 \\* :No such server
329 :cl1 raw :GLINE <test@example.com * 100000 :foo
330 :cl1 expect %srv1-name% 402 \\* :No such server