Update version number and copyright year.
[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
240def:y ${if def:tod_log{y}{n}}
241def:n ${if def:host{y}{n}}
242def:f ${if def:post{y}{n}}
243def:h_f ${if def:h_xxx {y}{n}}
244def:h_f ${if def:h_xxx:{y}{n}}
245def:d: ${if def:tod_log:{y}{n}}
246
247exists: ${if exists{/etc/passwd}{y}{n}}
248exists: ${if exists{/doesnt}{y}{n}}
249
250eq: ${if eq{abc}{abc}{y}{n}}
251eq: ${if eq{abc}{xyz}{y}{n}}
252!eq: ${if !eq{abc}{abc}{y}{n}}
253!eq: ${if !eq{abc}{xyz}{y}{n}}
254
255eqi: ${if eqi{abc}{abc}{y}{n}}
256eqi: ${if eqi{abc}{ABC}{y}{n}}
257eqi: ${if eqi{abc}{xyz}{y}{n}}
258!eqi: ${if !eqi{abc}{abc}{y}{n}}
259!eqi: ${if !eqi{abc}{aBc}{y}{n}}
260!eqi: ${if !eqi{abc}{xyz}{y}{n}}
261
262lt: ${if lt{ABC}{abc}{y}{n}}
263lti: ${if lti{ABC}{abc}{y}{n}}
264le: ${if le{ABC}{abc}{y}{n}}
265lei: ${if lei{ABC}{abc}{y}{n}}
266gt: ${if gt{ABC}{abc}{y}{n}}
267gti: ${if gti{ABC}{abc}{y}{n}}
268ge: ${if ge{ABC}{abc}{y}{n}}
269gei: ${if gei{ABC}{abc}{y}{n}}
270
271isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
272isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
273isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
274isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
275isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
276isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
277isip: ${if isip {::1}{y}{n}} ::1
278isip4: ${if isip4{::1}{y}{n}} ::1
279isip6: ${if isip6{::1}{y}{n}} ::1
280isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
281isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
282isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
283isip: ${if isip {rhubarb}{y}{n}} rhubarb
284isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
285isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
286
287match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
288match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
289match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
290match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
291match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
292
293match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
294match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
295match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
296match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
297match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
298
f78eb7c6
PH
299${if match{x@zz.aa.bb}{^(.*)} \
300 { \
301 >$1< \
302 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
303 >$1< \
304 } \
305 { CAN'T HAPPEN}}
306
307${if match{x@xxxabc}{^(.*)} \
308 { \
309 >$1< \
310 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
311 >$1< \
312 } \
313 { CAN'T HAPPEN}}
314
59371ea7
PH
315match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
316match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
317
318match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
319match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
320
321match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
322match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
323match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
324match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
325match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
326match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
327match_ip: 07 ${if match_ip{}{:4.5.6.7}}
328match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
329match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
330match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
331match_ip: 11 ${if match_ip{somename}{+hlist}}
332match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
333match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
334match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
335
336queue_running: ${if queue_running{y}{n}}
337first_delivery: ${if first_delivery{y}{n}}
338
339queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
340first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
341
342# Default values for both if strings
343
344\${if eq{1}{1}} >${if eq{1}{1}}<
345\${if eq{1}{2}} >${if eq{1}{2}}<
346
347# Lookups: DIR is the testing directory. In this test we can only use the
348# lookups that are required in all cases.
349
350${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
351
352${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
353${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
354${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
355${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
356
357${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
358${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
359${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
360${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
361${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
362${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
363${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
364
365q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
366q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
367q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
368q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
369q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
370q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
371q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
372
373abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
374a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
375ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
376xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
377Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
378Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
379a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
380a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
381a:b: ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
382a.b: ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
383a..b: ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
384a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
385a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
386
387# Should give the same results as above because expansion does nothing
388
389abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
390a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
391ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
392xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
393Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
394Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
395a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
396a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
397a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
398
399# Should fail because of no expansion
400
401a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
402a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
403a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
404a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
405
406# But these should succeed
407
408a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
409a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
410
366fc9f0
PH
411# Some tests of case-(in)dependence
412
413MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
414MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
415MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
416MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
417
59371ea7
PH
418# IP address (CIDR) lookups
419
4201.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
4211.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
4221.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
423abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
424192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
425192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
426abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
427abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
428abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
429rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
430
431
432# Nested Lookups - style 1
433
434${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
435${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
436
437# Nested Lookups - style 2
438
439${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
440${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
441
442# Other nesting tests
443
444${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}}}
445${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}}}
446${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}}}
447${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}}}
448
449# Lookup quotes for standardly expected lookups
450
451lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
452xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
453
454# Extract
455
456${extract{B}{A=1 B=2 C=3}}
457${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
458${extract{2}{:}{1:2:3}}
459${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
460Empty:<${extract{D}{A=1 B=2 C=3}}>
461Empty:<${extract{4}{:}{1:2:3}}>
462${extract{C}{A=1 B=2 C=3}{<$value>}}
463${extract{3}{:}{1:2:3}{<$value>}}
464Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
465Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
466${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
467${extract{4}{:}{1:2:3}{<$value>}{no 4}}
468${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
469${extract{4}{:}{1:2:3}{<$value>}fail}
470${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
471${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
472${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
473${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
474${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
475${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
476${extract{-3}{:,}{a,,b::c}}
477${extract{2}{:,}{a,,b::c}}
478${extract{3}{:,}{a,,b::c}}
479${extract{a-b}{X = "one two" a-b "three four" 5=99}}
480${extract{}{X=3}}
481${extract{ }{X=3}}
482${extract{ 2 }{ }{a b c}}
483
484# Translation
485
486abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
487abcdea a z ${tr{abcdea}{a}{z}}
488abcdea a ${tr{abcdea}{a}{}}
489abcdea abc z ${tr{abcdea}{abc}{z}}
490
491# RFC 2047
492
493abcd ${rfc2047:abcd}
494<:abcd:> ${rfc2047:<:abcd:>}
495<:ab cd:> ${rfc2047:<:ab cd:>}
496Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
497Long: ${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}
498
499
500# UTF-8
501
502abcd ${from_utf8:abcd}
503ad ${from_utf8:aÀÿd}
504toobig ${from_utf8:aĀd}
505
506# Substitution
507
508\${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
509\${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
510\${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
511\${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
512\${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
513\${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
514
515# File insertion
516
517${readfile}
518${readfile{DIR/aux-fixed/0002.readfile}}
519${readfile{DIR/aux-fixed/0002.readfile}{}}
520${readfile{DIR/aux-fixed/0002.readfile}{:}}
521${readfile{DIR/aux-fixed/0002.readfile}{ - }}
522${readfile{/non/exist/file}}
523${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
524>${readfile{DIR/aux-fixed/0002.readfile}{!}}\
525 <
526
527# Calling a command
528
529${run{DIR/aux-fixed/0002.runfile 0}}
530RC=$runrc
531${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
532RC=$runrc
533${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
534RC=$runrc
535${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
536RC=$runrc
537${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
538RC=$runrc
539${run{DIR/test-nonexist}{Y}{N}}
540RC=$runrc
541>>${run{DIR/bin/iefbr14}}<<
542RC=$runrc
543${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
544RC=$runrc
545
546# PRVS
547
548${prvs{userx@test.ex}{secret}}
549${prvs{userx@test.ex}{secret}{1}}
550${prvs{userx@test.ex}{secret}{8}}
551
552# Syntax errors
553
554${prvs{userx@test.ex}{secret}{12}}
555${prvs{userx@test.ex}{secret}{rhubarb}}
556${prvs{userx@test.ex}{secret}{}}
557
558# Correct checks; can't put explicit addresses in the tests, because they
559# will change over time.
560
561${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
562result=$prvscheck_result
563
564${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
565{>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
566result=$prvscheck_result
567
568${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
569result=$prvscheck_result
570
571# Incorrect secret
572
573${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
574result=$prvscheck_result
575
576${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
577result=$prvscheck_result
578
579# Non-prvs address
580
581>>${prvscheck{userx@test.ex}{secret}}<<
582result=$prvscheck_result
583
584# Syntax errors
585
586${tod_log
587${tod_log+6
588${expand:abcd
589${expand:abcd${tod_log}
590${hmac{xxx}{a}{b}}
591${if and {xyz}{a}{b}}
592${if and {{xya}}{a}{b}}
593${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
594${if eq {$h_xyz}{1}{y}{n}}
0d85fa3f
PH
595${if eq {$h_xyz:}{1}{y}{n}
596${if def:h_xyz}{y}{n}}
59371ea7
PH
597${if or {eq {}{}{yes}{no}}
598${if or {{eq {}{}{yes}{no}}
599${if or {{eq {}{}}{yes}{no}}
600${substr_1_:12345}
601${substr__3:12345}
602
603# Miscellaneous (for bug fixes, etc)
604
605${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
606
607****
608# Test "escape" with print_topbitchars
609exim -be -DPTBC=print_topbitchars
610escape: ${escape:B7F2}
611****
612# Checkout expansion debugging
613exim -d-all+expand -be
614primary_hostname: $primary_hostname
615match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
616match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
617${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
618match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
619****
620# Sender host name and address etc, all unset
621exim -be
622-oMa sender_host_address = $sender_host_address
623 sender_host_port = $sender_host_port
624-oMaa sender_host_authenticated = $sender_host_authenticated
625-oMai authenticated_id = $authenticated_id
626-oMas authenticated_sender = $authenticated_sender
627-oMi interface_address = $interface_address
628 interface_port = $interface_port
629-oMr received_protocol = $received_protocol
630-oMs sender_host_name = $sender_host_name
631-oMt sender_ident = $sender_ident
632****
633# Sender host name and address etc, all set except host name.
634exim -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
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-oMt sender_ident = $sender_ident
644****
645# Sender host name explicitly set
646exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
647-oMa sender_host_address = $sender_host_address
648 sender_host_port = $sender_host_port
649-oMs sender_host_name = $sender_host_name
650****
651# Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
652exim -be -oMa V4NET.11.12.13
653-oMs sender_host_name = $sender_host_name
654 host_lookup_failed = $host_lookup_failed
655****
656# Sender host name and protocol set by Sendmail-compatible option
657exim -be -pspecial:host.name
658-p received_protocol = $received_protocol
659-p sender_host_name = $sender_host_name
660****
661# Sender host name and address etc, all set except host name,
662# which should therefore be looked up from the address, but not if
663# we are skipping. The debug output for this test will show when
664# the lookup occurs.
665exim -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
666-oMa sender_host_address = $sender_host_address
667 sender_host_port = $sender_host_port
668-oMaa sender_host_authenticated = $sender_host_authenticated
669-oMai authenticated_id = $authenticated_id
670-oMas authenticated_sender = $authenticated_sender
671-oMi interface_address = $interface_address
672 interface_port = $interface_port
673-oMr received_protocol = $received_protocol
674----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
675-oMs sender_host_name = $sender_host_name
676-oMt sender_ident = $sender_ident
677****
678# Test no auto host name lookup for query-style lookups
679exim -d -bh V4NET.0.0.1
680****
681exim -d -bh V4NET.0.0.2
682****
683# Test $reply_address
684exim -bh V4NET.0.0.0
685mail from:<>
686rcpt to:<some@body>
687data
688.
689mail from:<>
690rcpt to:<some@body>
691data
692From: a@b
693.
694mail from:<>
695rcpt to:<some@body>
696data
697From: a@b
698Reply-to: c@d
699.
700mail from:<>
701rcpt to:<some@body>
702data
703Reply-to:
704.
705mail from:<>
706rcpt to:<some@body>
707data
708Reply-to:
709From: x@y
710.
711quit
712****
713# Check RFC 2047 decoding with (default) length check
714exim -bh V4NET.0.0.0
715mail from:<>
716rcpt to:<some@body>
717data
718Subject: =?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?=
719.
720quit
721****
722# Check RFC 2047 decoding with length check disabled
723exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
724mail from:<>
725rcpt to:<some@body>
726data
727Subject: =?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?=
728.
729quit
730****
1688f43b
PH
731# Certain kind of error
732exim -d -be
733match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
734match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}
735****