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