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