3 (* Check that we can iterate on directive *)
4 let _ = Httpd.directive+
6 (* Check that we can do a non iterative section *)
7 let _ = Httpd.section Httpd.directive
9 (* directives testing *)
10 let d1 = "ServerRoot \"/etc/apache2\"\n"
11 test Httpd.directive get d1 =
12 { "directive" = "ServerRoot"
13 { "arg" = "\"/etc/apache2\"" }
17 let d1s = "ServerRoot '/etc/apache2'\n"
18 test Httpd.directive get d1s =
19 { "directive" = "ServerRoot"
20 { "arg" = "'/etc/apache2'" }
23 let d2 = "ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/\n"
24 test Httpd.directive get d2 =
25 { "directive" = "ScriptAlias"
26 { "arg" = "/cgi-bin/" }
27 { "arg" = "/usr/lib/cgi-bin/" }
30 let d3 = "LockFile /var/lock/apache2/accept.lock\n"
31 test Httpd.directive get d3 =
32 { "directive" = "LockFile"
33 { "arg" = "/var/lock/apache2/accept.lock" }
47 test Httpd.lns get c1 = { }{ "IfModule" }
49 test Httpd.lns put c1 after set "/IfModule/arg[1]" "foo";
50 set "/IfModule/arg[2]" "bar" = c1_put
53 <IfModule !mpm_winnt.c>
54 <IfModule !mpm_netware.c>
55 LockFile /var/lock/apache2/accept.lock
60 test Httpd.lns get c2 =
63 { "arg" = "!mpm_winnt.c" }
65 { "arg" = "!mpm_netware.c" }
66 { "directive" = "LockFile"
67 { "arg" = "/var/lock/apache2/accept.lock" }
72 (* arguments must be the first child of the section *)
73 test Httpd.lns put c2 after rm "/IfModule/arg";
74 insb "arg" "/IfModule/*[1]";
75 set "/IfModule/arg" "foo" =
78 <IfModule !mpm_netware.c>
79 LockFile /var/lock/apache2/accept.lock
85 <IfModule mpm_event_module>
96 test Httpd.lns get c3 =
99 { "arg" = "mpm_event_module" }
100 { "directive" = "StartServers"
103 { "directive" = "MaxClients"
106 { "directive" = "MinSpareThreads"
109 { "directive" = "MaxSpareThreads"
112 { "directive" = "ThreadLimit"
115 { "directive" = "ThreadsPerChild"
118 { "directive" = "MaxRequestsPerChild"
133 test Httpd.lns get c4 =
137 { "arg" = "\"^\.ht\"" }
138 { "directive" = "Order"
139 { "arg" = "allow,deny" }
141 { "directive" = "Deny"
145 { "directive" = "Satisfy"
152 let c5 = "LogFormat \"%{User-agent}i\" agent\n"
153 test Httpd.lns get c5 =
154 { "directive" = "LogFormat"
155 { "arg" = "\"%{User-agent}i\"" }
159 let c7 = "LogFormat \"%v:%p %h %l %u %t \\"%r\\" %>s %O \\"%{Referer}i\\" \\"%{User-Agent}i\\"\" vhost_combined\n"
160 test Httpd.lns get c7 =
161 { "directive" = "LogFormat"
162 { "arg" = "\"%v:%p %h %l %u %t \\"%r\\" %>s %O \\"%{Referer}i\\" \\"%{User-Agent}i\\"\"" }
163 { "arg" = "vhost_combined" }
166 let c8 = "IndexIgnore .??* *~ *# RCS CVS *,v *,t \n"
167 test Httpd.directive get c8 =
168 { "directive" = "IndexIgnore"
178 (* FIXME: not yet supported:
179 * The backslash "\" may be used as the last character on a line to indicate
180 * that the directive continues onto the next line. There must be no other
181 * characters or white space between the backslash and the end of the line.
183 let multiline = "Options Indexes \
184 FollowSymLinks MultiViews
187 test Httpd.directive get multiline =
188 { "directive" = "Options"
189 { "arg" = "Indexes" }
190 { "arg" = "FollowSymLinks" }
191 { "arg" = "MultiViews" }
195 let conf2 = "<VirtualHost *:80>
196 ServerAdmin webmaster@localhost
198 DocumentRoot /var/www
200 Options FollowSymLinks
203 <Directory /var/www/>
204 Options Indexes FollowSymLinks MultiViews
210 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
211 <Directory \"/usr/lib/cgi-bin\">
213 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
218 ErrorLog /var/log/apache2/error.log
220 # Possible values include: debug, info, notice, warn, error, crit,
224 CustomLog /var/log/apache2/access.log combined
228 Alias /doc/ \"/usr/share/doc/\"
229 <Directory \"/usr/share/doc/\">
230 Options Indexes MultiViews FollowSymLinks
234 Allow from 127.0.0.0/255.0.0.0 ::1/128
240 test Httpd.lns get conf2 =
243 { "directive" = "ServerAdmin"
244 { "arg" = "webmaster@localhost" }
247 { "directive" = "DocumentRoot"
248 { "arg" = "/var/www" }
252 { "directive" = "Options"
253 { "arg" = "FollowSymLinks" }
255 { "directive" = "AllowOverride"
260 { "arg" = "/var/www/" }
261 { "directive" = "Options"
262 { "arg" = "Indexes" }
263 { "arg" = "FollowSymLinks" }
264 { "arg" = "MultiViews" }
266 { "directive" = "AllowOverride"
269 { "directive" = "Order"
270 { "arg" = "allow,deny" }
272 { "directive" = "allow"
278 { "directive" = "ScriptAlias"
279 { "arg" = "/cgi-bin/" }
280 { "arg" = "/usr/lib/cgi-bin/" }
283 { "arg" = "\"/usr/lib/cgi-bin\"" }
284 { "directive" = "AllowOverride"
287 { "directive" = "Options"
288 { "arg" = "+ExecCGI" }
289 { "arg" = "-MultiViews" }
290 { "arg" = "+SymLinksIfOwnerMatch" }
292 { "directive" = "Order"
293 { "arg" = "allow,deny" }
295 { "directive" = "Allow"
301 { "directive" = "ErrorLog"
302 { "arg" = "/var/log/apache2/error.log" }
305 { "#comment" = "Possible values include: debug, info, notice, warn, error, crit," }
306 { "#comment" = "alert, emerg." }
307 { "directive" = "LogLevel"
311 { "directive" = "CustomLog"
312 { "arg" = "/var/log/apache2/access.log" }
313 { "arg" = "combined" }
316 { "directive" = "SSLRequireSSL" }
318 { "directive" = "Alias"
320 { "arg" = "\"/usr/share/doc/\"" }
323 { "arg" = "\"/usr/share/doc/\"" }
324 { "directive" = "Options"
325 { "arg" = "Indexes" }
326 { "arg" = "MultiViews" }
327 { "arg" = "FollowSymLinks" }
329 { "directive" = "AllowOverride"
332 { "directive" = "Order"
333 { "arg" = "deny,allow" }
335 { "directive" = "Deny"
339 { "directive" = "Allow"
341 { "arg" = "127.0.0.0/255.0.0.0" }
342 { "arg" = "::1/128" }
349 test Httpd.lns get "<a> # a comment
353 { "#comment" = "a comment" }
354 { "directive" = "MyDirective" { "arg" = "Foo" } } }
356 test Httpd.lns get "<a>
359 { "a" { "#comment" = "a comment" } }
362 Newlines inside quoted value (GH issue #104) *)
363 test Httpd.lns get "Single 'Foo\\
367 { "directive" = "Single"
368 { "arg" = "'Foo\\\nbar'" } }
369 { "directive" = "Double"
370 { "arg" = "\"Foo\\\nbar\"" } }
373 Support >= in tags (GH #154) *)
376 <IfModule !proxy_ajp_module>
377 LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
382 <IfModule !proxy_ajp_module>
383 LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
388 test Httpd.lns get versioncheck =
394 { "arg" = "!proxy_ajp_module" }
395 { "directive" = "LoadModule"
396 { "arg" = "proxy_ajp_module" }
397 { "arg" = "modules/mod_proxy_ajp.so" }
406 { "arg" = "!proxy_ajp_module" }
407 { "directive" = "LoadModule"
408 { "arg" = "proxy_ajp_module" }
409 { "arg" = "modules/mod_proxy_ajp.so" }
416 let double_comment = "<IfDefine Foo>
422 test Httpd.lns get double_comment =
426 { "#comment" = "# Comment" }
430 let single_comment = "<IfDefine Foo>
436 test Httpd.lns get single_comment =
439 { "#comment" = "# Comment" }
443 let single_empty = "<IfDefine Foo>
447 test Httpd.lns get single_empty =
452 let eol_empty = "<IfDefine Foo> #
454 test Httpd.lns get eol_empty =
460 test Httpd.lns get "<IfModule mod_ssl.c>
465 { "arg" = "mod_ssl.c" }
466 { "#comment" = "one comment" }
467 { "#comment" = "another comment" }