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