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