Flush SMTP output buffer before "delay" in an ACL; add control =
[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.
7
8exim -be
9
10# These expansions can test variables in the configuration, but as there
11# is no message being processed, there is no message-related data. But
12# that of course gets tested in plenty of other places.
13
14# Some fixed variables
15
16exim_path: $exim_path
17primary_hostname: $primary_hostname
18primary_hostname: ${primary_hostname}
19qualify_domain: $qualify_domain
20bounce_return_size_limit: ${bounce_return_size_limit}
21spool_directory: $spool_directory
22unknown: ${unknown}
23h_subject: $h_subject:(should be empty)
24h_subject:$h_subject (should be empty)
25header in curlies: ${header_subject:} (should fail)
26
27# \$message_headers should be empty
28message_headers: >$message_headers<
29
30# Continuation
31x\
32y
33x\
34 y
35
36# Overlong names and overbig numbers
37
38+$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
39+${aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
40+$11111111111111111111111111111111111
41+${11111111111111111111111111111111111}
42
43# Operators
44
45addrss: ${address:local-part@dom.ain}
46addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
47domain: ${domain:local-part@dom.ain}
48domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
49escape: ${escape:B7F2}
50eval: ${eval:1+1}
51eval: ${eval:1+2*3}
52eval: ${eval:(1+2)*3}
53eval: ${eval:3/2*4}
54eval: ${eval:3*4/2}
55eval: ${eval:42}
56eval: ${eval:}
57eval: ${eval:-2}
58eval: ${eval:-2 - -3}
59eval: ${eval:-2 - (-3)}
60eval: ${eval:-2 - (-3}
61eval: ${eval:-2 - -3)}
62eval: ${eval:-2 --3}
63eval: ${eval:-2 -+3}
64eval: ${eval:-2 -+-3}
65eval: ${eval:(2*(1+1))/2 + 40K}
66eval: ${eval:077}
67eval: ${eval:08}
68eval10: ${eval10:077}
69eval10: ${eval10:08}
af561417
PH
70eval10: ${eval10:0x1234}
71eval: ${eval:2+42%5}
72eval: ${eval:0xc&5}
73eval: ${eval:0xc & 5 }
74eval: ${eval:0x0c|5}
75eval: ${eval:0xc^5}
76eval: ${eval:0xc>>1}
77eval: ${eval:0xc >> 2}
78eval: ${eval:0xc >> 4 }
79eval: ${eval:0xc<<1}
80eval: ${eval:~255&0x1234}
81eval: ${eval:~ 255&0x1234}
82eval: ${eval: -(~255&0x1234)}
83
59371ea7
PH
84expand: \$primary_hostname ${expand:\$primary_hostname}
85hash: ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
86hash: ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
87hex2b64:${hex2b64:12345678}
88hex2b64:${hex2b64:abcdef}
89hex2b64:${hex2b64:ABCDEF}
90hex2b64:${hex2b64:1a2b3c4d5e6f}
91hex2b64:${hex2b64:1a2b3c4d5e6}
92hex2b64:${hex2b64:1a2b3c4d5e6g}
93hex2b64:${hex2b64:${md5:the quick brown fox}}
94hex2b64:${hex2b64:${sha1:the quick brown fox}}
95
96The base62 operator is actually a base36 operator in the Darwin and Cygwin
97environments. Write cunning tests that produce the same output in both cases,
98while doing a reasonable check.
99
100base62: ${if or {\
101 {eq {${base62:12345}}{0003D7}}\
102 {eq {${base62:12345}}{0009IX}}\
103 }{OK}{NOT OK}}
104base62d: ${if or {\
105 {eq {${base62d:0003D7}}{12345}}\
106 {eq {${base62d:0009IX}}{12345}}\
107 }{OK}{NOT OK}}
108base62d: ${if or {\
109 {eq {${base62d:3D7}}{12345}}\
110 {eq {${base62d:9IX}}{12345}}\
111 }{OK}{NOT OK}}
112base62 error: ${base62:12345x}
113base62d error:${base62d:0003D7.}
114
115hmac: ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
116hmac: ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
117md5: ${md5:the quick brown fox jumps over the lazy dog}
118sha1: ${sha1:}
119sha1: ${sha1:abc}
120mask: ${mask:192.168.10.206/28}
121mask: ${mask:192.168.10.206/32}
122mask: ${mask:192.168.10.206/33}
123mask: ${mask:192.168.10.206/0}
124mask: ${mask:192.168.10.206}
125mask: ${mask:a.b.c.d}
126nhash: ${nhash_24:monty} ${nhash_8_63:monty python}
127lc/uc: ${lc:The Quick} ${uc: Brown Fox}
128length: ${length_10:The quick brown fox} ${l_10:abc}
129lclpt: ${local_part:local-part@dom.ain}
130lclpt: ${local_part:Exim Person <local-part@dom.ain> (that's me)}
131quote: ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
132quote: ${quote:nl(\n)}
133quote: ${quote:cr(\r)}
134quote: ${quote:tab(\t)}
135quote: ${quote:xff(\xff)}
136quote: Empty>${quote:}<
137quote_local_part: ${quote_local_part:abcd}
138quote_local_part: ${quote_local_part:O'Reilly}
139quote_local_part: ${quote_local_part:a space}
140quote_local_part: ${quote_local_part:.something}
141quote_local_part: ${quote_local_part:something.}
142quote_local_part: ${quote_local_part:joe.bloggs}
143quote_local_part: ${quote_local_part:a!b}
144quote_local_part: ${quote_local_part:x@y}
145quote_local_part: ${quote_local_part:ab*cd}
146quote_local_part: ${quote_local_part:x:y}
147quote_local_part: ${quote_local_part:ab\cd"ef}
148quote_local_part: ${quote_local_part:}
149rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
150substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
151substr: ${s_3:rhubarb} ${s_-2:rhubarb}
152substr: ${s_1:}
153substr: ${substr_10:abc}
154str2b64:${str2b64:abcd}
155str2b64:${str2b64:The quick brown \n fox}
156strlen: ${strlen:}
157strlen: ${strlen:a}
158strlen: ${strlen:abcdefgh}
f90d018c
PH
159time_eval: ${time_eval:10s}
160time_eval: ${time_eval:2h}
161time_eval: ${time_eval:1d5m}
162time_eval: ${time_eval:1w2d3h4m5s}
163time_eval: ${time_eval:14}
164time_eval: ${time_eval:rhubarb}
59371ea7
PH
165time_interval: ${time_interval:0}
166time_interval: ${time_interval:44}
167time_interval: ${time_interval:999999}
168time_interval: ${time_interval:-1}
169time_interval: ${time_interval:rhubarb}
170
171# stat is a bit tricky, but some of the fields of the aux-var directory
172# should be the same on all systems
173
174stat: ${extract{mode}{${stat:DIR/aux-var}}}
175stat: ${extract{smode}{${stat:DIR/aux-var}}}
176stat: ${stat:/a/non/existent/file}
177
178# "Operators" that have expanded arguments
179
180hash: ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
181hash: ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
182nhash: ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
183length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
184substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
185substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
186
187# Error forms
188
189${hash{one}}
190${hash{nonnumber}{abcd}}
191${hash{3}{2}{4}{abcd}}
192${substr{-3}{-2}{abcd}}
193
194# Skipped operators
195
196addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
197domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
198escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
199expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
200hash: ${if eq {1}{2}{${hash_3:invalid}}{NO}}
201md5: ${if eq {1}{2}{${md5:invalid}}{NO}}
202mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
203
d45b1de8
PH
204# Numeric overflow
205
2064096M ${if >{1}{4096M}{y}{n}}
2074096000000 ${if >{1}{4096000000}{y}{n}}
208
59371ea7
PH
209# Conditions
210
2112=2: ${if ={2}{2}{y}{n}}
2122==2: ${if =={2}{2}{y}{n}}
2133=2: ${if ={3}{2}{y}{n}}
2142==3: ${if =={2}{3}{y}{n}}
215!2=2: ${if !={2}{2}{y}{n}}
216!2==2: ${if !=={2}{2}{y}{n}}
217!3=2: ${if !={3}{2}{y}{n}}
218!2==3: ${if !=={2}{3}{y}{n}}
2192>3: ${if >{2}{3}{y}{n}}
2203>3: ${if >{3}{3}{y}{n}}
2214>3: ${if >{4}{3}{y}{n}}
d45b1de8 2221>-1: ${if >{1}{-1}{y}{n}}
59371ea7
PH
2232>=3: ${if >={2}{3}{y}{n}}
2243>=3: ${if >={3}{3}{y}{n}}
2254>=3: ${if >={4}{3}{y}{n}}
2262<3: ${if <{2}{3}{y}{n}}
2273<3: ${if <{3}{3}{y}{n}}
2284<3: ${if <{4}{3}{y}{n}}
2292<=3: ${if <={2}{3}{y}{n}}
2303<=3: ${if <={3}{3}{y}{n}}
2314<=3: ${if <={4}{3}{y}{n}}
2325<=3: ${if <={ 5 } { 3 } {y}{n}}
d45b1de8 233-3<=1: ${if <={-3}{1}{y}{n}}
59371ea7
PH
234
2355>3k: ${if >{5 } {3k }{y}{n}}
2365>3m: ${if >{5 } {3m }{y}{n}}
2375>3z: ${if >{5 } {3z }{y}{n}}
2385>a: ${if >{ 5 } {a}{y}{n}}
239
5dd1517f
PH
240>0: ${if > {}{0}{y}{n}}
241=: ${if = {}{}{y}{n}}
242-2<: ${if < {-2}{}{y}{n}}
24308>07: ${if > {08}{07}{y}{n}}
244011=11: ${if = {011}{11}{y}{n}}
245
59371ea7
PH
246def:y ${if def:tod_log{y}{n}}
247def:n ${if def:host{y}{n}}
248def:f ${if def:post{y}{n}}
249def:h_f ${if def:h_xxx {y}{n}}
250def:h_f ${if def:h_xxx:{y}{n}}
251def:d: ${if def:tod_log:{y}{n}}
252
253exists: ${if exists{/etc/passwd}{y}{n}}
254exists: ${if exists{/doesnt}{y}{n}}
255
256eq: ${if eq{abc}{abc}{y}{n}}
257eq: ${if eq{abc}{xyz}{y}{n}}
258!eq: ${if !eq{abc}{abc}{y}{n}}
259!eq: ${if !eq{abc}{xyz}{y}{n}}
260
261eqi: ${if eqi{abc}{abc}{y}{n}}
262eqi: ${if eqi{abc}{ABC}{y}{n}}
263eqi: ${if eqi{abc}{xyz}{y}{n}}
264!eqi: ${if !eqi{abc}{abc}{y}{n}}
265!eqi: ${if !eqi{abc}{aBc}{y}{n}}
266!eqi: ${if !eqi{abc}{xyz}{y}{n}}
267
268lt: ${if lt{ABC}{abc}{y}{n}}
269lti: ${if lti{ABC}{abc}{y}{n}}
270le: ${if le{ABC}{abc}{y}{n}}
271lei: ${if lei{ABC}{abc}{y}{n}}
272gt: ${if gt{ABC}{abc}{y}{n}}
273gti: ${if gti{ABC}{abc}{y}{n}}
274ge: ${if ge{ABC}{abc}{y}{n}}
275gei: ${if gei{ABC}{abc}{y}{n}}
276
277isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
278isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
279isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
280isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
281isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
282isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
283isip: ${if isip {::1}{y}{n}} ::1
284isip4: ${if isip4{::1}{y}{n}} ::1
285isip6: ${if isip6{::1}{y}{n}} ::1
286isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
287isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
288isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
289isip: ${if isip {rhubarb}{y}{n}} rhubarb
290isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
291isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
292
293match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
294match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
295match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
296match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
297match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
298
299match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
300match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
301match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
302match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
303match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
304
f78eb7c6
PH
305${if match{x@zz.aa.bb}{^(.*)} \
306 { \
307 >$1< \
308 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
309 >$1< \
310 } \
311 { CAN'T HAPPEN}}
312
313${if match{x@xxxabc}{^(.*)} \
314 { \
315 >$1< \
316 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
317 >$1< \
318 } \
319 { CAN'T HAPPEN}}
320
59371ea7
PH
321match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
322match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
323
324match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
325match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
326
327match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
328match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
329match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
330match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
331match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
332match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
333match_ip: 07 ${if match_ip{}{:4.5.6.7}}
334match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
335match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
336match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
337match_ip: 11 ${if match_ip{somename}{+hlist}}
338match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
339match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
340match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
341
342queue_running: ${if queue_running{y}{n}}
343first_delivery: ${if first_delivery{y}{n}}
344
345queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
346first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
347
348# Default values for both if strings
349
350\${if eq{1}{1}} >${if eq{1}{1}}<
351\${if eq{1}{2}} >${if eq{1}{2}}<
352
353# Lookups: DIR is the testing directory. In this test we can only use the
354# lookups that are required in all cases.
355
356${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
357
358${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
359${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
360${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
361${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
362
363${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
364${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
365${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
366${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
367${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
368${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
369${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
370
371q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
372q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
373q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
374q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
375q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
376q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
377q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
378
379abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
380a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
381ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
382xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
383Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
384Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
385a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
386a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
387a:b: ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
388a.b: ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
389a..b: ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
390a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
391a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
392
393# Should give the same results as above because expansion does nothing
394
395abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
396a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
397ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
398xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
399Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
400Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
401a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
402a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
403a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
404
405# Should fail because of no expansion
406
407a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
408a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
409a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
410a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
411
412# But these should succeed
413
414a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
415a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
416
366fc9f0
PH
417# Some tests of case-(in)dependence
418
419MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
420MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
421MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
422MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
423
59371ea7
PH
424# IP address (CIDR) lookups
425
4261.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
4271.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
4281.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
429abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
430192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
431192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
432abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
433abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
434abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
435rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
436
437
438# Nested Lookups - style 1
439
440${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
441${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
442
443# Nested Lookups - style 2
444
445${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
446${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
447
448# Other nesting tests
449
450${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}}}
451${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}}}
452${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}}}
453${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}}}
454
455# Lookup quotes for standardly expected lookups
456
457lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
458xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
459
460# Extract
461
462${extract{B}{A=1 B=2 C=3}}
463${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
464${extract{2}{:}{1:2:3}}
465${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
466Empty:<${extract{D}{A=1 B=2 C=3}}>
467Empty:<${extract{4}{:}{1:2:3}}>
468${extract{C}{A=1 B=2 C=3}{<$value>}}
469${extract{3}{:}{1:2:3}{<$value>}}
470Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
471Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
472${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
473${extract{4}{:}{1:2:3}{<$value>}{no 4}}
474${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
475${extract{4}{:}{1:2:3}{<$value>}fail}
476${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
477${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
478${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
479${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
480${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
481${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
482${extract{-3}{:,}{a,,b::c}}
483${extract{2}{:,}{a,,b::c}}
484${extract{3}{:,}{a,,b::c}}
485${extract{a-b}{X = "one two" a-b "three four" 5=99}}
486${extract{}{X=3}}
487${extract{ }{X=3}}
488${extract{ 2 }{ }{a b c}}
489
490# Translation
491
492abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
493abcdea a z ${tr{abcdea}{a}{z}}
494abcdea a ${tr{abcdea}{a}{}}
495abcdea abc z ${tr{abcdea}{abc}{z}}
496
497# RFC 2047
498
499abcd ${rfc2047:abcd}
500<:abcd:> ${rfc2047:<:abcd:>}
501<:ab cd:> ${rfc2047:<:ab cd:>}
502Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
503Long: ${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}
504
9c57cbc0
PH
505# RFC 2047 decode
506
507${rfc2047d:abcd abcd}
508${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
509${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
510${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?=}
511${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
512
513# UTF-8
514
515abcd ${from_utf8:abcd}
516ad ${from_utf8:aÀÿd}
517toobig ${from_utf8:aĀd}
518
519# Substitution
520
521\${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
522\${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
523\${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
524\${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
525\${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
526\${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
527
528# File insertion
529
530${readfile}
531${readfile{DIR/aux-fixed/0002.readfile}}
532${readfile{DIR/aux-fixed/0002.readfile}{}}
533${readfile{DIR/aux-fixed/0002.readfile}{:}}
534${readfile{DIR/aux-fixed/0002.readfile}{ - }}
535${readfile{/non/exist/file}}
536${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
537>${readfile{DIR/aux-fixed/0002.readfile}{!}}\
538 <
539
540# Calling a command
541
542${run{DIR/aux-fixed/0002.runfile 0}}
543RC=$runrc
544${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
545RC=$runrc
546${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
547RC=$runrc
548${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
549RC=$runrc
550${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
551RC=$runrc
552${run{DIR/test-nonexist}{Y}{N}}
553RC=$runrc
554>>${run{DIR/bin/iefbr14}}<<
555RC=$runrc
556${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
557RC=$runrc
558
559# PRVS
560
561${prvs{userx@test.ex}{secret}}
562${prvs{userx@test.ex}{secret}{1}}
563${prvs{userx@test.ex}{secret}{8}}
564
565# Syntax errors
566
567${prvs{userx@test.ex}{secret}{12}}
568${prvs{userx@test.ex}{secret}{rhubarb}}
569${prvs{userx@test.ex}{secret}{}}
570
571# Correct checks; can't put explicit addresses in the tests, because they
572# will change over time.
573
574${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
575result=$prvscheck_result
576
577${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
578{>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
579result=$prvscheck_result
580
581${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
582result=$prvscheck_result
583
584# Incorrect secret
585
586${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
587result=$prvscheck_result
588
589${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
590result=$prvscheck_result
591
592# Non-prvs address
593
594>>${prvscheck{userx@test.ex}{secret}}<<
595result=$prvscheck_result
596
597# Syntax errors
598
599${tod_log
600${tod_log+6
601${expand:abcd
602${expand:abcd${tod_log}
603${hmac{xxx}{a}{b}}
604${if and {xyz}{a}{b}}
605${if and {{xya}}{a}{b}}
606${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
607${if eq {$h_xyz}{1}{y}{n}}
0d85fa3f
PH
608${if eq {$h_xyz:}{1}{y}{n}
609${if def:h_xyz}{y}{n}}
59371ea7
PH
610${if or {eq {}{}{yes}{no}}
611${if or {{eq {}{}{yes}{no}}
612${if or {{eq {}{}}{yes}{no}}
613${substr_1_:12345}
614${substr__3:12345}
615
616# Miscellaneous (for bug fixes, etc)
617
618${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
619
620****
621# Test "escape" with print_topbitchars
622exim -be -DPTBC=print_topbitchars
623escape: ${escape:B7F2}
624****
625# Checkout expansion debugging
626exim -d-all+expand -be
627primary_hostname: $primary_hostname
628match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
629match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
630${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
631match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
632****
633# Sender host name and address etc, all unset
634exim -be
635-oMa sender_host_address = $sender_host_address
636 sender_host_port = $sender_host_port
637-oMaa sender_host_authenticated = $sender_host_authenticated
638-oMai authenticated_id = $authenticated_id
639-oMas authenticated_sender = $authenticated_sender
640-oMi interface_address = $interface_address
641 interface_port = $interface_port
642-oMr received_protocol = $received_protocol
643-oMs sender_host_name = $sender_host_name
644-oMt sender_ident = $sender_ident
645****
646# Sender host name and address etc, all set except host name.
647exim -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
648-oMa sender_host_address = $sender_host_address
649 sender_host_port = $sender_host_port
650-oMaa sender_host_authenticated = $sender_host_authenticated
651-oMai authenticated_id = $authenticated_id
652-oMas authenticated_sender = $authenticated_sender
653-oMi interface_address = $interface_address
654 interface_port = $interface_port
655-oMr received_protocol = $received_protocol
656-oMt sender_ident = $sender_ident
657****
658# Sender host name explicitly set
659exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
660-oMa sender_host_address = $sender_host_address
661 sender_host_port = $sender_host_port
662-oMs sender_host_name = $sender_host_name
663****
664# Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
665exim -be -oMa V4NET.11.12.13
666-oMs sender_host_name = $sender_host_name
667 host_lookup_failed = $host_lookup_failed
668****
669# Sender host name and protocol set by Sendmail-compatible option
670exim -be -pspecial:host.name
671-p received_protocol = $received_protocol
672-p sender_host_name = $sender_host_name
673****
674# Sender host name and address etc, all set except host name,
675# which should therefore be looked up from the address, but not if
676# we are skipping. The debug output for this test will show when
677# the lookup occurs.
678exim -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
679-oMa sender_host_address = $sender_host_address
680 sender_host_port = $sender_host_port
681-oMaa sender_host_authenticated = $sender_host_authenticated
682-oMai authenticated_id = $authenticated_id
683-oMas authenticated_sender = $authenticated_sender
684-oMi interface_address = $interface_address
685 interface_port = $interface_port
686-oMr received_protocol = $received_protocol
687----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
688-oMs sender_host_name = $sender_host_name
689-oMt sender_ident = $sender_ident
690****
691# Test no auto host name lookup for query-style lookups
692exim -d -bh V4NET.0.0.1
693****
694exim -d -bh V4NET.0.0.2
695****
696# Test $reply_address
697exim -bh V4NET.0.0.0
698mail from:<>
699rcpt to:<some@body>
700data
701.
702mail from:<>
703rcpt to:<some@body>
704data
705From: a@b
706.
707mail from:<>
708rcpt to:<some@body>
709data
710From: a@b
711Reply-to: c@d
712.
713mail from:<>
714rcpt to:<some@body>
715data
716Reply-to:
717.
718mail from:<>
719rcpt to:<some@body>
720data
721Reply-to:
722From: x@y
723.
724quit
725****
726# Check RFC 2047 decoding with (default) length check
727exim -bh V4NET.0.0.0
728mail from:<>
729rcpt to:<some@body>
730data
731Subject: =?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?=
732.
733quit
734****
735# Check RFC 2047 decoding with length check disabled
736exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
737mail from:<>
738rcpt to:<some@body>
739data
740Subject: =?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?=
741.
742quit
743****
1688f43b
PH
744# Certain kind of error
745exim -d -be
746match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
747match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}
748****