Quota checking during reception. Bug 163
[users/jgh/exim.git] / test / scripts / 0000-Basic / 0002
1 # Common string expansions
2 #
3 # This is the main string expansion test that tests those expansions that will
4 # be present in the basic Exim binary which we require in order to run these
5 # tests at all. Specialized expansion tests also exist for optional features
6 # in other test scripts.
7 munge dnssec
8
9 exim -be
10
11 # These expansions can test variables in the configuration, but as there
12 # is no message being processed, there is no message-related data. But
13 # that of course gets tested in plenty of other places.
14
15 # Some fixed variables
16
17 exim_path: $exim_path
18 exim_version: $exim_version
19 config_dir: $config_dir
20 config_file: $config_file
21 primary_hostname: $primary_hostname
22 primary_hostname: ${primary_hostname}
23 qualify_domain: $qualify_domain
24 bounce_return_size_limit: ${bounce_return_size_limit}
25 spool_directory: $spool_directory
26 queue_name: $queue_name
27 unknown: ${unknown}
28 h_subject: $h_subject:(should be empty)
29 h_subject:$h_subject (should be empty)
30 header in curlies: ${header_subject:} (should fail)
31
32 # \$message_headers should be empty
33 message_headers: >$message_headers<
34
35 # Continuation
36 x\
37 y
38 x\
39              y
40
41 # Overlong names and overbig numbers
42
43 +$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
44 +${aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
45 +$11111111111111111111111111111111111
46 +${11111111111111111111111111111111111}
47
48 eval:   ${eval:0}
49 eval:   ${eval:1}
50 eval:   ${eval:-1}
51 eval:   ${eval:+1}
52 eval:   ${eval:1+1}
53 eval:   ${eval:1+2*3}
54 eval:   ${eval:(1+2)*3}
55 eval:   ${eval:3/2*4}
56 eval:   ${eval:3*4/2}
57 eval:   ${eval:42}
58 eval:   ${eval:}
59 eval:   ${eval:-2}
60 eval:   ${eval:-2 - -3}
61 eval:   ${eval:-2 - (-3)}
62 eval:   ${eval:-2 - (-3}
63 eval:   ${eval:-2 - -3)}
64 eval:   ${eval:-2 --3}
65 eval:   ${eval:-2 -+3}
66 eval:   ${eval:-2 -+-3}
67 eval:   ${eval:(2*(1+1))/2 + 40K}
68 eval:   ${eval:077}
69 eval:   ${eval:08}
70 eval10: ${eval10:077}
71 eval10: ${eval10:08}
72 eval10: ${eval10:0x1234}
73 eval:   ${eval:2+42%5}
74 eval:   ${eval:0xc&5}
75 eval:   ${eval:0xc & 5 }
76 eval:   ${eval:0x0c|5}
77 eval:   ${eval:0xc^5}
78 eval:   ${eval:0xc>>1}
79 eval:   ${eval:0xc >> 2}
80 eval:   ${eval:0xc >> 4 }
81 eval:   ${eval:0xc<<1}
82 eval:   ${eval:~255&0x1234}
83 eval:   ${eval:~ 255&0x1234}
84 eval:   ${eval: -(~255&0x1234)}
85
86 # List operations
87
88 filter: "${filter{a:b:c}{eq{1}{1}}}"
89 filter: ${filter{a:b:c}{!eq{$item}{b}}}
90 filter: ${filter{<' a'b'c}{!eq{$item}{b}}}
91 filter: ${filter{<' ''a'b' ''c}{!eq{$item}{b}}}
92 filter: "${filter{}{!eq{$item}{b}}}"
93
94 map: "${map{}{$item}}"
95 map: ${map{a:b:c}{$item}}
96 map: ${map{a:b:c}{:$item:}}
97 map: ${if eq{1}{0}{${map{a:b:c}{:$item:}}}{fail string}}
98 map: ${map{:b:c}{[$item]}}
99
100 reduce: "${reduce{}{+}{$value$item}}"
101 reduce: ${reduce{a:b:c}{+}{$value$item}}
102 reduce: ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}
103 reduce: ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}
104 # Check for extract corrupting reduce's $value
105 reduce: ${reduce {b}{a aaa}{${extract{1}{ }{$value}} , $item}}
106
107 listnamed: ${listnamed:dlist}
108 listnamed: ${listnamed:+dlist}
109 listnamed: ${listnamed:hlist}
110 listnamed: ${listnamed:elist}
111 listnamed: ${listnamed:flist}
112 listnamed: ${listnamed:nolist}
113 listnamed: ${listnamed_d:dlist}
114 listnamed: ${listnamed_d:hlist}
115 listnamed: ${listnamed_z:dlist}
116
117 listcount: ${listcount:a:b:c}
118 listcount: ${listcount:}
119 listcount: ${listcount:<;a;b;c}
120 listcount: ${listcount:${listnamed:dlist}}
121
122 listextract: ${listextract{ 2}{a:b:c:d}}
123 listextract: ${listextract{-2}{<,a,b,c,d}{X${value}X}}
124 listextract: ${listextract{ 5}{a:b:c:d}}
125 listextract: ${listextract{-5}{a:b:c:d}}
126 listextract: ${listextract{ 5}{a:b:c:d}{}{fail}}
127 listextract: ${listextract{ 5}{a:b:c:d}{}fail}
128
129 listquote: ${listquote{:}{abcd}}
130 listquote: ${listquote{:}{ab:cd}}
131 listquote: ${listquote{:}{:a:b:c:d:}}
132 listquote: ${listquote{:}{ab::cd}}
133 listquote: ${listquote{;}{ab:cd}}
134 listquote: ${listquote{;}{ab;cd}}
135 listquote: ${listquote{ }{ ab cd}}
136
137 sort: ${sort{3:2:1:4}{<}{$item}}
138 sort: ${sort {<, 3,2,1,4}{>}{$item}}
139 sort: ${sort{c:B:a:aa}{lti}{$item}}
140 sort: ${sort{666 r99.ex.com:10 smtp.ex.com:100 r2.ex.com}{<}{${sg {$item}{([0-9]*).*\$}{\$1}}}}
141 sort: ${sort{666,r99.ex.com:10,smtp.ex.com:100,r2.ex.com}{<}{${listextract{1}{<,$item}}}}
142 sort: "${sort{}{<}{$item}}"
143
144 # Tests with iscntrl() and illegal separators
145
146 map: ${map{<\n a\n\nb\nc}{'$item'}}
147
148 reduce: ${reduce {<n 1\n2\n3}{0}{${eval:$value+$item}}}
149 reduce: ${reduce {<\n 1\n2\n3}{0}{${eval:$value+$item}}}
150 reduce: ${reduce { <\n 1\n 2 \n 3 }{0}{${eval:$value+$item}}}
151 reduce: ${reduce {<\x7f 1\x7f2\177 3}{0}{${eval:$value+$item}}}
152
153 # Operators
154
155 acl: ${acl
156 acl: ${acl}
157 acl: ${acl {a_nosuch}}
158 acl: ${acl {a_ret}}
159 acl: ${acl {a_ret}{person@dom.ain}}
160 acl: ${acl {a_ret}{firstarg}{secondarg}}
161 acl: ${acl {a_ret}{arg with spaces}}
162 acl: ${acl {a_none}}
163 acl: ${acl {a_none}{person@dom.ain}}
164 acl: ${acl {a_deny}}
165 acl: ${acl {a_deny}{person@dom.ain}}
166 acl: ${acl {a_defer}}
167 acl: ${acl {a_sub}{top_arg_1}{top_arg_2}{top_arg_3}}
168 acl: ${reduce {1:2:3:4} {} {$value ${acl {a_ret}{$item}}}}
169
170 addrss: ${address:local-part@dom.ain}
171 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
172 addrss: ${address:Exim Person <local-part(comment)@dom.ain> (that's me)}
173 addrss: ${address:Exim Person <local-part@dom.ain(comment)> (that's me)}
174 addrss: ${address:Exim Person <local-part(comment)@dom.ain(comment2)> (that's me)}
175 addrss: ${address:Exim Person <local-part.(comment)dot-atom@dom.ain(comment2)> (that's me)}
176 addrss: ${address:Exim Person <(comment)local-part@dom.ain(comment2)> (that's me)}
177 domain: ${domain:local-part@dom.ain}
178 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
179 domain: ${domain:Exim Person <local-part(foo)@(bar)dom.ain> (that's me)}
180 domain: ${domain:a.b.c}
181
182 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
183 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
184 addresses: ${addresses:>+ Exim Person <local-part@dom.ain> (that's me),\
185            xyz@abc}
186 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
187            xyz@abc, nullgroupname:;, group: p@q, r@s; }
188 addresses: ${addresses:local-part@dom.ain <local-part@dom.ain>}
189 addresses: ${addresses:>}
190
191 escape:     ${escape:B7·F2ò}
192 excape8bit: ${escape8bit:undisturbed text\ttab\nnewline\ttab\\backslash \176tilde\177DEL\200\x81.}
193
194 expand: \$primary_hostname ${expand:\$primary_hostname}
195 hash:   ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
196 hash:   ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
197 hex2b64:${hex2b64:12345678}
198 hex2b64:${hex2b64:abcdef}
199 hex2b64:${hex2b64:ABCDEF}
200 hex2b64:${hex2b64:1a2b3c4d5e6f}
201 hex2b64:${hex2b64:1a2b3c4d5e6}
202 hex2b64:${hex2b64:1a2b3c4d5e6g}
203 hex2b64:${hex2b64:${md5:the quick brown fox}}
204 hex2b64:${hex2b64:${sha1:the quick brown fox}}
205
206 base32: 0  <${base32:0}>
207 base32: 1  <${base32:1}>
208 base32: 31 <${base32:31}>
209 base32: 32 <${base32:32}>
210 base32: 42 <${base32:42}>
211 base32 error: 0x1 ${base32:0x1}
212
213 base32d: 0  ${base32d:${base32:0}}
214 base32d: 1  ${base32d:${base32:1}}
215 base32d: 31 ${base32d:${base32:31}}
216 base32d: 32 ${base32d:${base32:32}}
217 base32d: 42 ${base32d:${base32:42}}
218 base32d error: ABC ${base32d:ABC}
219
220 the base62 operator is actually a base36 operator in the Darwin and Cygwin
221 environments. Write cunning tests that produce the same output in both cases,
222 while doing a reasonable check.
223
224 base62:  ${if or {\
225                  {eq {${base62:12345}}{0003D7}}\
226                  {eq {${base62:12345}}{0009IX}}\
227                  }{OK}{NOT OK}}
228 base62d: ${if or {\
229                  {eq {${base62d:0003D7}}{12345}}\
230                  {eq {${base62d:0009IX}}{12345}}\
231                  }{OK}{NOT OK}}
232 base62d: ${if or {\
233                  {eq {${base62d:3D7}}{12345}}\
234                  {eq {${base62d:9IX}}{12345}}\
235                  }{OK}{NOT OK}}
236 base62 error: ${base62:12345x}
237 base62d error:${base62d:0003D7.}
238
239 hmac:   ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
240 hmac:   ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
241 md5:    ${md5:the quick brown fox jumps over the lazy dog}
242 sha1:   ${sha1:}
243 sha1:   ${sha1:abc}
244 mask:   ${mask:192.168.10.206/28}
245 mask:   ${mask:192.168.10.206/32}
246 mask:   ${mask:192.168.10.206/33}
247 mask:   ${mask:192.168.10.206/0}
248 mask:   ${mask:192.168.10.206}
249 mask:   ${mask:a.b.c.d}
250 ipv6denorm: ${ipv6denorm:::1}
251 ipv6denorm: ${ipv6denorm:fe00::1}
252 ipv6denorm: ${ipv6denorm:192.168.0.1}
253 ipv6denorm: ${ipv6denorm:fe80::192.168.0.1}
254 ipv6norm:   ${ipv6norm:0:0:0::1}
255 ipv6norm:   ${ipv6norm:2a00::0}
256 ipv6norm:   ${ipv6norm:2a00::1}
257 ipv6norm:   ${ipv6norm:2a00:eadf:0000:0000:0000:0000:0001:0000}
258 ipv6norm:   ${ipv6norm:2a00:eadf:0000:0001:0000:0000:0000:0000}
259 ipv6norm:   ${ipv6norm:2a00:0:0:0::}
260 ipv6norm:   ${ipv6norm:2a00:2:3:4:5:6:7:8}
261 nhash:  ${nhash_24:monty} ${nhash_8_63:monty python}
262 lc/uc:  ${lc:The Quick} ${uc: Brown Fox}
263 length: ${length_10:The quick brown fox} ${l_10:abc}
264 lclpt:  ${local_part:local-part@dom.ain}
265 lclpt:  ${local_part:Exim Person <local-part@dom.ain> (that's me)}
266 lclpt:  ${local_part:Exim Person <local(comment).part@dom.(comment2)ain> (that's me)}
267 lclpt:  ${local_part:a.b.c}
268 quote:  ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
269 quote:  ${quote:nl(\n)}
270 quote:  ${quote:cr(\r)}
271 quote:  ${quote:tab(\t)}
272 quote:  ${quote:xff(\xff)}
273 quote:  Empty>${quote:}<
274 quote_local_part: ${quote_local_part:abcd}
275 quote_local_part: ${quote_local_part:O'Reilly}
276 quote_local_part: ${quote_local_part:a space}
277 quote_local_part: ${quote_local_part:.something}
278 quote_local_part: ${quote_local_part:something.}
279 quote_local_part: ${quote_local_part:joe.bloggs}
280 quote_local_part: ${quote_local_part:a!b}
281 quote_local_part: ${quote_local_part:x@y}
282 quote_local_part: ${quote_local_part:ab*cd}
283 quote_local_part: ${quote_local_part:x:y}
284 quote_local_part: ${quote_local_part:ab\cd"ef}
285 quote_local_part: ${quote_local_part:}
286 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
287 hexquote: ${hexquote:\
288     \001\002\003\004\005\006\007 \010\011\012\013\014\015\016\017 \
289 \020\021\022\023\024\025\026\027 \030\031\032\033\034\035\036\037 \
290 \040\041\042\043\044\045\046\047 \050\051\052\053\054\055\056\057 \
291 \060\061\062\063\064\065\066\067 \070\071\072\073\074\075\076\077 \
292 \100\101\102\103\104\105\106\107 \110\111\112\113\114\115\116\117 \
293 \120\121\122\123\124\125\126\127 \130\131\132\133\134\135\136\137 \
294 \140\141\142\143\144\145\146\147 \150\151\152\153\154\155\156\157 \
295 \160\161\162\163\164\165\166\167 \170\171\172\173\174\175\176\177}
296 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
297 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
298 substr: ${s_1:}
299 substr: ${substr_10:abc}
300 str2b64:${str2b64:abcd}
301 str2b64:${str2b64:The quick brown \n fox}
302 base64: ${base64:abcd}
303 base64: ${base64:The quick brown \n fox}
304 base64d:${base64d:YWJjZA==}
305 base64d:${base64d:VGhlIHF1aWNrIGJyb3duIAogZm94}
306 strlen: ${strlen:}
307 strlen: ${strlen:a}
308 strlen: ${strlen:abcdefgh}
309 time_eval:     ${time_eval:10s}
310 time_eval:     ${time_eval:2h}
311 time_eval:     ${time_eval:1d5m}
312 time_eval:     ${time_eval:1w2d3h4m5s}
313 time_eval:     ${time_eval:14}
314 time_eval:     ${time_eval:rhubarb}
315 time_interval: ${time_interval:0}
316 time_interval: ${time_interval:44}
317 time_interval: ${time_interval:999999}
318 time_interval: ${time_interval:-1}
319 time_interval: ${time_interval:rhubarb}
320
321 # stat is a bit tricky, but some of the fields of the aux-var directory
322 # should be the same on all systems
323
324 stat:   ${extract{mode}{${stat:DIR/aux-var}}}
325 stat:   ${extract{smode}{${stat:DIR/aux-var}}}
326 stat:   ${stat:/a/non/existent/file}
327
328 # "Operators" that have expanded arguments
329
330 hash:   ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
331 hash:   ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
332 nhash:  ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
333 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
334 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
335 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
336
337 # Error forms
338
339 ${hash{one}}
340 ${hash{nonnumber}{abcd}}
341 ${hash{3}{2}{4}{abcd}}
342 ${substr{-3}{-2}{abcd}}
343
344 # Skipped operators
345
346 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
347 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
348 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
349 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
350 hash:   ${if eq {1}{2}{${hash_3:invalid}}{NO}}
351 md5:    ${if eq {1}{2}{${md5:invalid}}{NO}}
352 mask:   ${if eq {1}{2}{${mask:invalid}}{NO}}
353
354 # Number suffixes in conditions
355 1k: ${if >{1}{1k}{n}{y}}
356 1K: ${if >{1}{1K}{n}{y}}
357 1M: ${if >{1}{1M}{n}{y}}
358 1G: ${if >{1}{1G}{n}{y}}
359
360 # Numeric overflow
361 # >32b should work, >64b not
362
363 1 > 2047M                ${if >{1}{2047M}{y}{n}}
364 1 > 2048M                ${if >{1}{2048M}{y}{n}}
365 1 > 4096000000           ${if >{1}{4096000000}{y}{n}}
366 1 > 4096M                ${if >{1}{4096M}{y}{n}}
367 1 > 4611686018427387904  ${if >{1}{4611686018427387904} {y}{n}}
368 1 > 46116860184273879040 ${if >{1}{46116860184273879040}{y}{n}}
369
370 # Conditions
371
372 2=2:    ${if ={2}{2}{y}{n}}
373 2==2:   ${if =={2}{2}{y}{n}}
374 3=2:    ${if ={3}{2}{y}{n}}
375 2==3:   ${if =={2}{3}{y}{n}}
376 !2=2:   ${if !={2}{2}{y}{n}}
377 !2==2:  ${if !=={2}{2}{y}{n}}
378 !3=2:   ${if !={3}{2}{y}{n}}
379 !2==3:  ${if !=={2}{3}{y}{n}}
380 2>3:    ${if >{2}{3}{y}{n}}
381 3>3:    ${if >{3}{3}{y}{n}}
382 4>3:    ${if >{4}{3}{y}{n}}
383 1>-1:   ${if >{1}{-1}{y}{n}}
384 2>=3:   ${if >={2}{3}{y}{n}}
385 3>=3:   ${if >={3}{3}{y}{n}}
386 4>=3:   ${if >={4}{3}{y}{n}}
387 2<3:    ${if <{2}{3}{y}{n}}
388 3<3:    ${if <{3}{3}{y}{n}}
389 4<3:    ${if <{4}{3}{y}{n}}
390 2<=3:   ${if <={2}{3}{y}{n}}
391 3<=3:   ${if <={3}{3}{y}{n}}
392 4<=3:   ${if <={4}{3}{y}{n}}
393 5<=3:   ${if <={ 5 } { 3 } {y}{n}}
394 -3<=1:  ${if <={-3}{1}{y}{n}}
395
396 5>3k:   ${if >{5 } {3k }{y}{n}}
397 5>3m:   ${if >{5 } {3m }{y}{n}}
398 5>3z:   ${if >{5 } {3z }{y}{n}}
399 5>a:    ${if >{ 5 } {a}{y}{n}}
400 5>bad:  ${if >{5 } {${lookup{trick}lsearch{DIR/aux-fixed/0002.lsearch}}} {y}{n}}
401
402 >0:     ${if > {}{0}{y}{n}}
403 =:      ${if = {}{}{y}{n}}
404 -2<:    ${if < {-2}{}{y}{n}}
405 08>07:  ${if > {08}{07}{y}{n}}
406 011=11: ${if = {011}{11}{y}{n}}
407
408 def:y   ${if def:tod_log{y}{n}}
409 def:n   ${if def:host{y}{n}}
410 def:f   ${if def:post{y}{n}}
411 def:h_f ${if def:h_xxx {y}{n}}
412 def:h_f ${if def:h_xxx:{y}{n}}
413 def:d:  ${if def:tod_log:{y}{n}}
414
415 exists: ${if exists{/etc/passwd}{y}{n}}
416 exists: ${if exists{/doesnt}{y}{n}}
417
418 eq:     ${if eq{abc}{abc}{y}{n}}
419 eq:     ${if eq{abc}{xyz}{y}{n}}
420 !eq:    ${if !eq{abc}{abc}{y}{n}}
421 !eq:    ${if !eq{abc}{xyz}{y}{n}}
422
423 eqi:    ${if eqi{abc}{abc}{y}{n}}
424 eqi:    ${if eqi{abc}{ABC}{y}{n}}
425 eqi:    ${if eqi{abc}{xyz}{y}{n}}
426 !eqi:   ${if !eqi{abc}{abc}{y}{n}}
427 !eqi:   ${if !eqi{abc}{aBc}{y}{n}}
428 !eqi:   ${if !eqi{abc}{xyz}{y}{n}}
429
430 lt:     ${if lt{ABC}{abc}{y}{n}}
431 lti:    ${if lti{ABC}{abc}{y}{n}}
432 le:     ${if le{ABC}{abc}{y}{n}}
433 lei:    ${if lei{ABC}{abc}{y}{n}}
434 gt:     ${if gt{ABC}{abc}{y}{n}}
435 gti:    ${if gti{ABC}{abc}{y}{n}}
436 ge:     ${if ge{ABC}{abc}{y}{n}}
437 gei:    ${if gei{ABC}{abc}{y}{n}}
438
439 isip:   ${if isip {1.2.3.4}{y}{n}}  1.2.3.4
440 isip4:  ${if isip4{1.2.3.4}{y}{n}}  1.2.3.4
441 isip6:  ${if isip6{1.2.3.4}{y}{n}}  1.2.3.4
442 isip:   ${if isip {::1.2.3.256}{y}{n}}  ::1.2.3.256
443 isip4:  ${if isip4{1.2.3.256}{y}{n}}  1.2.3.256
444 isip:   ${if isip {1:2:3:4}{y}{n}}  1:2:3:4
445 isip4:  ${if isip4{1:2:3:4}{y}{n}}  1:2:3:4
446 isip6:  ${if isip6{1:2:3:4}{y}{n}}  1:2:3:4
447 isip:   ${if isip {::1}{y}{n}}      ::1
448 isip4:  ${if isip4{::1}{y}{n}}      ::1
449 isip6:  ${if isip6{::1}{y}{n}}      ::1
450 isip:   ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
451 isip4:  ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
452 isip6:  ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
453 isip:   ${if isip {fe80::1.2.3.4}{y}{n}}  fe80::1.2.3.4
454 isip:   ${if isip {rhubarb}{y}{n}}  rhubarb
455 isip4:  ${if isip4{rhubarb}{y}{n}}  rhubarb
456 isip6:  ${if isip6{rhubarb}{y}{n}}  rhubarb
457
458 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
459 match:  ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
460 match:  ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
461 match:  ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
462 match:  ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
463
464 match_domain:    ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
465 match_domain:    ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
466 match_domain:    ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
467 match_domain:    ${if match_domain{xxxyz}{+dlist}{yes}{no}}
468 match_domain:    ${if match_domain{xyz}{+dlist}{yes}{no}}
469
470 ${if match{x@zz.aa.bb}{^(.*)} \
471   { \
472   >$1< \
473   ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
474   >$1< \
475   } \
476   { CAN'T HAPPEN}}
477
478 ${if match{x@xxxabc}{^(.*)} \
479   { \
480   >$1< \
481   ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
482   >$1< \
483   } \
484   { CAN'T HAPPEN}}
485
486 match_address:   ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
487 match_address:   ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
488
489 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
490 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
491
492 match_ip:        01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
493 match_ip:        02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
494 match_ip:        03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
495 match_ip:        04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
496 match_ip:        05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
497 match_ip:        06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
498 match_ip:        07 ${if match_ip{}{:4.5.6.7}}
499 match_ip:        08 ${if match_ip{V4NET.11.12.13}{+hlist}}
500 match_ip:        09 ${if match_ip{V4NET.11.12.14}{+hlist}}
501 match_ip:        10 ${if match_ip{192.168.3.4}{+hlist}}
502 match_ip:        11 ${if match_ip{somename}{+hlist}}
503 match_ip:        12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
504 match_ip:        13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
505 match_ip:        14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
506 match_ip:        15 ${if match_ip{abcd::dcba}{net-iplsearch;DIR/aux-fixed/0002.matchip}}
507
508 queue_running:  ${if queue_running{y}{n}}
509 first_delivery: ${if first_delivery{y}{n}}
510
511 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
512 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
513
514 # acl expansion condition
515 acl if: ${if acl {{a_ret}}               {Y:$value}{N:$value}}
516 acl if: ${if acl {{a_ret}{argY}}         {Y:$value}{N:$value}}
517 acl if: ${if acl {{a_deny}{argN}{arg2}}  {Y:$value}{N:$value}}
518 acl if: ${if acl {{a_defer}{argN}{arg2}} {Y:$value}{N:$value}}
519
520 # Default values for both if strings
521
522 \${if eq{1}{1}}  >${if eq{1}{1}}<
523 \${if eq{1}{2}}  >${if eq{1}{2}}<
524
525 # Lookups: DIR is the testing directory. In this test we can only use the
526 # lookups that are required in all cases.
527
528 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
529
530 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
531 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
532 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
533 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
534
535 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
536 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
537 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
538 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
539 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
540 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
541 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
542
543 q1:  ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
544 q2:  ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
545 q3:  ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
546 q4:  ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
547 q5:  ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
548 q6:  ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
549 q7:  ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
550
551 abc:   ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
552 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
553 ab.c:  ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
554 xyz:   ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
555 .Xyz:   ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
556 .Zyz:   ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
557 a b:   ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
558 a  b:  ${lookup{a  b}wildlsearch{DIR/aux-var/0002.wild}}
559 a:b:   ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
560 a.b:   ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
561 a..b:  ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
562 a9b:   ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
563 a99b:  ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
564
565 # Should give the same results as above because expansion does nothing
566
567 abc:   ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
568 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
569 ab.c:  ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
570 xyz:   ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
571 .Xyz:   ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
572 .Zyz:   ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
573 a b:   ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
574 a  b:  ${lookup{a  b}nwildlsearch{DIR/aux-var/0002.wild}}
575 a:b:   ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
576
577 # Should fail because of no expansion
578
579 a.b:   ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
580 a..b:  ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
581 a9b:   ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
582 a99b:  ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
583
584 # But these should succeed
585
586 a\\:b:  ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
587 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
588
589 # Some tests of case-(in)dependence
590
591 .MiXeD-CD:  ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
592 .MixeD-CD:  ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
593 .MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
594 .MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
595
596 # IP address (CIDR) lookups
597
598 1.2.3.4:      ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
599 1.2.3.5:      ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
600 1.2.3.5:      ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
601 abcd::cdab:   ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
602 192.168.1.2:  ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
603 192.168.5.6:  ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
604 abcd:abcd::   ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
605 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
606 abcd:abcd::3  ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
607 rhubarb       ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
608
609
610 # Nested Lookups - style 1
611
612 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
613 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
614
615 # Nested Lookups - style 2
616
617 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
618 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
619
620 # Other nesting tests
621
622 ${lookup{one}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{one}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{one}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
623 ${lookup{two}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{two}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{two}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
624 ${lookup{both}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{both}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{both}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
625 ${lookup{neither}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{neither}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{neither}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
626
627 # Lookup quotes for standardly expected lookups
628
629 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
630 xxx     ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
631
632 # Extract
633
634 ${extract{B}{A=1 B=2 C=3}}
635 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
636 ${extract{2}{:}{1:2:3}}
637 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
638 empty:<${extract{D}{A=1 B=2 C=3}}>
639 empty:<${extract{4}{:}{1:2:3}}>
640 ${extract{C}{A=1 B=2 C=3}{<$value>}}
641 ${extract{3}{:}{1:2:3}{<$value>}}
642 empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
643 empty:<${extract{4}{:}{1:2:3}{<$value>}}>
644 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
645 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
646 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
647 ${extract{4}{:}{1:2:3}{<$value>}fail}
648 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
649 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
650 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
651 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
652 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
653 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
654 ${extract{-3}{:,}{a,,b::c}}
655 ${extract{2}{:,}{a,,b::c}}
656 ${extract{3}{:,}{a,,b::c}}
657 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
658 ${extract{}{X=3}}
659 ${extract{ }{X=3}}
660 ${extract{ 2 }{ }{a b c}}
661
662 ${map{a,1:b,2:c,3}{${extract{1}{,}{$item}{$value}{}}}}
663 ${map{a,1:b,2:c,3}{${extract{1}{,}{$item}{$value}{failcase}{bogus_argument}}}}
664 ${map{a,1:b,2:c,3}{${extract{1}{,}{$item}{$value}fail}}}
665
666 # Translation
667
668 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
669 abcdea a   z   ${tr{abcdea}{a}{z}}
670 abcdea a       ${tr{abcdea}{a}{}}
671 abcdea abc z   ${tr{abcdea}{abc}{z}}
672
673 # Boolean
674 "TrUe"                ${if bool{TrUe}{true}{false}}      EXPECT: true
675 "FALSE"               ${if bool{FALSE}{true}{false}}     EXPECT: false
676 " yes"                ${if bool{ yes}{true}{false}}      EXPECT: true
677 " no"                 ${if bool{ no}{true}{false}}     EXPECT: false
678 "yes "                ${if bool{yes }{true}{false}}      EXPECT: true
679 "-1"                  ${if bool{-1}{true}{false}}     EXPECT: true
680 "0"                   ${if bool{0}{true}{false}}     EXPECT: false
681 "1"                   ${if bool{1}{true}{false}}      EXPECT: true
682 " 0 "                 ${if bool{ 0 }{true}{false}}     EXPECT: false
683 " 1 "                 ${if bool{ 1 }{true}{false}}      EXPECT: true
684 "1111111111111111111" ${if bool{1111111111111111111}{true}{false}}      EXPECT: true
685 "9"                   ${if bool{9}{true}{false}}      EXPECT: true
686 " "                   ${if bool{ }{true}{false}}     EXPECT: false
687 "text"                ${if bool{text}{true}{false}}     EXPECT: error
688 " text"               ${if bool{ text}{true}{false}}     EXPECT: error
689 "-text"               ${if bool{-text}{true}{false}}     EXPECT: error
690 "text "               ${if bool{text }{true}{false}}     EXPECT: error
691 " text "              ${if bool{ text }{true}{false}}     EXPECT: error
692 "00"                  ${if bool{00}{true}{false}}     EXPECT: false
693 "!true"               ${if !bool{true}{true}{false}}     EXPECT: false
694 "!false"              ${if !bool{false}{true}{false}}      EXPECT: true
695
696 "TrUe"                ${if bool_lax{TrUe}{true}{false}}      EXPECT: true
697 "FALSE"               ${if bool_lax{FALSE}{true}{false}}     EXPECT: false
698 " yes"                ${if bool_lax{ yes}{true}{false}}      EXPECT: true
699 " no"                 ${if bool_lax{ no}{true}{false}}     EXPECT: false
700 "yes "                ${if bool_lax{yes }{true}{false}}      EXPECT: true
701 "-1"                  ${if bool_lax{-1}{true}{false}}      EXPECT: true
702 "0"                   ${if bool_lax{0}{true}{false}}     EXPECT: false
703 "1"                   ${if bool_lax{1}{true}{false}}      EXPECT: true
704 " 0 "                 ${if bool_lax{ 0 }{true}{false}}     EXPECT: false
705 " 1 "                 ${if bool_lax{ 1 }{true}{false}}      EXPECT: true
706 "1111111111111111111" ${if bool_lax{1111111111111111111}{true}{false}}      EXPECT: true
707 "9"                   ${if bool_lax{9}{true}{false}}      EXPECT: true
708 " "                   ${if bool_lax{ }{true}{false}}     EXPECT: false
709 "text"                ${if bool_lax{text}{true}{false}}      EXPECT: true
710 " text"               ${if bool_lax{ text}{true}{false}}      EXPECT: true
711 "text "               ${if bool_lax{text }{true}{false}}      EXPECT: true
712 " text "              ${if bool_lax{ text }{true}{false}}      EXPECT: true
713 "00"                  ${if bool_lax{00}{true}{false}}      EXPECT: true
714 "!true"               ${if !bool_lax{true}{true}{false}}     EXPECT: false
715 "!false"              ${if !bool_lax{false}{true}{false}}      EXPECT: true
716
717 # RFC 2047
718
719 abcd      ${rfc2047:abcd}
720 <:abcd:>  ${rfc2047:<:abcd:>}
721 <:ab cd:> ${rfc2047:<:ab cd:>}
722 long:     ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
723 long:     ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit by a long way; in fact this one will go over the 150 character limit}
724
725 # RFC 2047 decode
726
727 ${rfc2047d:abcd      abcd}
728 ${rfc2047d:<:abcd:>  =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
729 ${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
730 ${rfc2047d:Long:     =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit?=}
731 ${rfc2047d:Long:     =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fac?= =?iso-8859-8?Q?t_this_one_will_go_over_the_150_character_limit?=}
732
733 # UTF-8
734
735 abcd      ${from_utf8:abcd}
736 aÀÿd      ${from_utf8:aÃ\80ÿd}
737 toobig    ${from_utf8:aĀd}
738
739 # Substitution
740
741 \${sg{abcdefabcdef}{abc}{xyz}}          =${sg{abcdefabcdef}{abc}{xyz}}
742 \${sg{ab:xy::z}{:}{::}}                 =${sg{ab:xy::z}{:}{::}}
743 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}    =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
744 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}}   =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
745 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
746 \${sg{abbab}{a*}{+}}                    =${sg{abbab}{a*}{+}}
747
748 # File insertion
749
750 ${readfile}
751 ${readfile{DIR/aux-fixed/0002.readfile}}
752 ${readfile{DIR/aux-fixed/0002.readfile}{}}
753 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
754 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
755 ${readfile{/non/exist/file}}
756 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
757 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
758     <
759
760 # Calling a command
761
762 ${run{DIR/aux-fixed/0002.runfile 0}}
763 rc=$runrc
764 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
765 rc=$runrc
766 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
767 rc=$runrc
768 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
769 rc=$runrc
770 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
771 rc=$runrc
772 ${run{DIR/test-nonexist}{Y}{N}}
773 rc=$runrc
774 >>${run{DIR/bin/iefbr14}}<<
775 rc=$runrc
776 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
777 rc=$runrc
778
779 # PRVS
780
781 ${prvs{userx@test.ex}{secret}}
782 ${prvs{userx@test.ex}{secret}{1}}
783 ${prvs{userx@test.ex}{secret}{8}}
784
785 # Syntax errors
786
787 ${prvs{userx@test.ex}{secret}{12}}
788 ${prvs{userx@test.ex}{secret}{rhubarb}}
789 ${prvs{userx@test.ex}{secret}{}}
790
791 # Correct checks; can't put explicit addresses in the tests, because they
792 # will change over time.
793
794 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
795 result=$prvscheck_result
796
797 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
798 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
799 result=$prvscheck_result
800
801 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
802 result=$prvscheck_result
803
804 # Incorrect secret
805
806 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
807 result=$prvscheck_result
808
809 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
810 result=$prvscheck_result
811
812 # Non-prvs address
813
814 >>${prvscheck{userx@test.ex}{secret}}<<
815 result=$prvscheck_result
816
817 # Syntax errors
818
819 ${tod_log
820 ${tod_log+6
821 ${expand:abcd
822 ${expand:abcd${tod_log}
823 ${hmac{xxx}{a}{b}}
824 ${if and {xyz}{a}{b}}
825 ${if and {{xya}}{a}{b}}
826 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
827 ${if eq {$h_xyz}{1}{y}{n}}
828 ${if eq {$h_xyz:}{1}{y}{n}
829 ${if def:h_xyz}{y}{n}}
830 ${if or {eq {}{}{yes}{no}}
831 ${if or {{eq {}{}{yes}{no}}
832 ${if or {{eq {}{}}{yes}{no}}
833 ${substr_1_:12345}
834 ${substr__3:12345}
835
836 # Iterations: forany and forall
837
838 ${if forany{a:b:c}{eq{$item}{a}}{yes}{no}}
839 ${if forany{a:b:c}{eq{$item}{b}}{yes}{no}}
840 ${if forany{a:b:c}{eq{$item}{c}}{yes}{no}}
841 ${if forany {a:b:c} {eq {$item} {z}} {yes} {no}}
842 ${if !forany{a:b:c}{eq{$item}{z}}{yes}{no}}
843 ${if !forany{a:b:c}{eq{$item}{a}}{yes}{no}}
844 ${if forany{}{eq{$item}{a}}{yes}{no}}
845 ${if !forany{}{eq{$item}{a}}{yes}{no}}
846 ${if forany{<, $primary_hostname,foo,bar}{eq{$item}{$primary_hostname}}{yes}{no}}
847
848 ${if forany{}{yes}{no}}
849 ${if forany{a:b:c}{gt{$item}{a}{yes}{no}}
850
851 ${if forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
852 ${if forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
853 ${if forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
854 ${if forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
855
856 ${if !forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
857 ${if !forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
858 ${if !forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
859 ${if !forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
860
861 # Expect yes
862 ${if forany{a:b:c}\
863   {\
864   eq\
865     {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
866     {$item: true}\
867   }\
868 {outer=yes}{outer=no}} item='$item' (unset)
869
870 # Expect no
871 ${if forany{a:b:c}\
872   {\
873   eq\
874     {$item: ${if !forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
875     {$item: true}\
876   }\
877 {outer=yes}{outer=no}}
878
879 # Error inside nest - check message is helpful
880 ${if forany{a:b:c}\
881   {\
882   eq\
883     {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}{true}{false}}}\
884     {$item: true}\
885   }\
886 {outer=yes}{outer=no}}
887
888
889 # Miscellaneous (for bug fixes, etc)
890
891 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
892
893 # Environment access
894
895 ${env {USER}}
896 ${env {NO_SUCH_VARIABLE} {oops, success} {correct}}
897
898 # JSON
899
900 ${extract json {Url} \
901   {   \{ \"Url\":    \"http://www.example.com/image/481989943\",\
902          \"Height\": 125,\
903          \"Width\":  100\
904       \} \
905   } \
906  }
907 ${extract json {Width} \
908   {   \{ \"Url\":    \"http://www.example.com/image/481989943\",\
909          \"Height\": 125,\
910          \"Width\":  100\
911       \} \
912   } \
913  }
914 ${extract json {2} {[116, 943, 234, 38793]} }
915 ${extract json {2} {${extract json{IDs} {\{"other":"foo", "IDs": [116, 943, 234]\} }}} }
916
917 ${extract json {2} {["red", "green", "blue", "black"]} }
918 ${extract jsons{2} {["red", "green", "blue", "black"]} }
919 <${extract jsons{5} {["red", "green", "blue", "black"]} }>
920 expect: <>
921
922 ${extract json {seconds} { \{"hours":0, "mins":0, "seconds":59\} }}
923 ${extract json {seconds} {${extract json {2} { ["irrelevant", \{"hours":0, "mins":0, "seconds":59\}] }}}}
924
925 ${extract json{IDs}{ \{"IDs": \{"1":116, "2":943, "3":234\}\} }}
926 expect: {"1":116, "2":943, "3":234}
927
928 ${extract json{IDs}{ \{"id": \{"a":101, "b":102\}, "IDs": \{"1":116, "2":943, "3":234\}\} }}
929 expect: {"1":116, "2":943, "3":234}
930
931 <${extract json{nonexistent}{ \{"id": \{"a":101, "b":102\}, "IDs": \{"1":116, "2":943, "3":234\}\} }}>
932 expect: <>
933 <${extract jsons{nonexistent}{ \{"id": \{"a":101, "b":102\}, "IDs": \{"1":116, "2":943, "3":234\}\} }}>
934 expect: <>
935
936 ${if forany_json {[1, 2, 3]}{={$item}{1}}{yes}{no}}
937 ${if forany_jsons{["A", "B", "C"]}{eq{$item}{B}}{yes}{no}}
938
939 ****
940 # Test "escape" with print_topbitchars
941 exim -be -DPTBC=print_topbitchars
942 escape: ${escape:B7·F2ò}
943 ****
944 # Checkout expansion debugging
945 exim -d-all+expand -f sndr@dom -be
946 primary_hostname: $primary_hostname
947 sender_address: $sender_address
948 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
949 match:  ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
950 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
951 match_address:   ${if match_address{a.b.c}{a.b.c}{yes}{no}}
952 ****
953 exim -d-all+expand+noutf8 -be
954 primary_hostname: $primary_hostname
955 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
956 match:  ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
957 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
958 match_address:   ${if match_address{a.b.c}{a.b.c}{yes}{no}}
959 ****
960 # Sender host name and address etc, all unset
961 exim -be
962 -be Sender host name and address etc, all unset
963 -oMa  sender_host_address = $sender_host_address
964       sender_host_port = $sender_host_port
965 -oMaa sender_host_authenticated = $sender_host_authenticated
966 -oMai authenticated_id = $authenticated_id
967 -oMas authenticated_sender = $authenticated_sender
968 -oMi  interface_address = $interface_address
969       interface_port = $interface_port
970 -oMr  received_protocol = $received_protocol
971 -oMs  sender_host_name = $sender_host_name
972 -oMt  sender_ident = $sender_ident
973 ****
974 # Sender host name and address etc, all set except host name.
975 exim -d-all+expand -be -oMa V4NET.0.0.1.1234 -oMaa AAA -oMai philip -oMas xx@yy.zz -oMi 1.1.1.1.99 -oMr special -oMt me
976 -be Sender host name and address etc, all set except host name.
977 -oMa  sender_host_address = $sender_host_address
978       sender_host_port = $sender_host_port
979 -oMaa sender_host_authenticated = $sender_host_authenticated
980 -oMai authenticated_id = $authenticated_id
981 -oMas authenticated_sender = $authenticated_sender
982 -oMi  interface_address = $interface_address
983       interface_port = $interface_port
984 -oMr  received_protocol = $received_protocol
985 -oMt  sender_ident = $sender_ident
986 ****
987 # Sender host name explicitly set
988 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
989 -be Sender host name explicitly set
990 -oMa  sender_host_address = $sender_host_address
991       sender_host_port = $sender_host_port
992 -oMs  sender_host_name = $sender_host_name
993 ****
994 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
995 exim -be -oMa V4NET.11.12.13
996 be Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
997 -oMs  sender_host_name = $sender_host_name
998       host_lookup_failed = $host_lookup_failed
999 ****
1000 # Sender host name and protocol set by Sendmail-compatible option
1001 exim -be -pspecial:host.name
1002 -be Sender host name and protocol set by Sendmail-compatible option
1003 -p  received_protocol = $received_protocol
1004 -p  sender_host_name = $sender_host_name
1005 ****
1006 # Sender host name and address etc, all set except host name,
1007 # which should therefore be looked up from the address, but not if
1008 # we are skipping. The debug output for this test will show when
1009 # the lookup occurs.
1010 exim -d-all+host_lookup+expand -be -oMa V4NET.0.0.1.1234 -oMaa AAA -oMai philip -oMas xx@yy.zz -oMi 1.1.1.1.99 -oMr special -oMt me
1011 -be Sender host name and address etc, all set except host name
1012 -oMa  sender_host_address = $sender_host_address
1013       sender_host_port = $sender_host_port
1014 -oMaa sender_host_authenticated = $sender_host_authenticated
1015 -oMai authenticated_id = $authenticated_id
1016 -oMas authenticated_sender = $authenticated_sender
1017 -oMi  interface_address = $interface_address
1018       interface_port = $interface_port
1019 -oMr  received_protocol = $received_protocol
1020 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
1021 -oMs  sender_host_name = $sender_host_name
1022 -oMt  sender_ident = $sender_ident
1023 ****
1024 # Test no auto host name lookup for query-style lookups
1025 exim -d -bh V4NET.0.0.1
1026 ****
1027 exim -d -bh V4NET.0.0.2
1028 ****
1029 # Test $reply_address
1030 exim -bh V4NET.0.0.0
1031 mail from:<>
1032 rcpt to:<some@body>
1033 data
1034 .
1035 mail from:<>
1036 rcpt to:<some@body>
1037 data
1038 From: a@b
1039 .
1040 mail from:<>
1041 rcpt to:<some@body>
1042 data
1043 From: a@b
1044 Reply-to: c@d
1045 .
1046 mail from:<>
1047 rcpt to:<some@body>
1048 data
1049 Reply-to:
1050 .
1051 mail from:<>
1052 rcpt to:<some@body>
1053 data
1054 Reply-to:
1055 From: x@y
1056 .
1057 quit
1058 ****
1059 # Check RFC 2047 decoding with (default) length check
1060 exim -bh V4NET.0.0.0
1061 mail from:<>
1062 rcpt to:<some@body>
1063 data
1064 Subject: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_it_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fact_this_one_will_go_over_the_150_character_limit?=
1065 .
1066 quit
1067 ****
1068 # Check RFC 2047 decoding with length check disabled
1069 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
1070 mail from:<>
1071 rcpt to:<some@body>
1072 data
1073 Subject: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_it_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fact_this_one_will_go_over_the_150_character_limit?=
1074 .
1075 quit
1076 ****
1077 # Certain kind of error
1078 exim -d -be
1079 match_ip:        15 ${if match_ip{1.2.3.4}{1.2.3}}
1080 match_ip:        16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}
1081 ****
1082 # Operation of inlist and negated inlist
1083 exim -be
1084 ${if inlist{aa}{aa} {in list}{not in list}}
1085 ${if !inlist{aa}{aa} {not in list}{in list}}
1086 ****