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