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