1#!/usr/bin/env perl
2BEGIN {
3	# add current source dir to the include-path
4	# we need this for make distcheck
5	(my $srcdir = $0) =~ s,/[^/]+$,/,;
6	unshift @INC, $srcdir;
7}
8
9use strict;
10use IO::Socket;
11use Test::More tests => 10;
12use LightyTest;
13
14my $tf = LightyTest->new();
15my $t;
16
17$tf->{CONFIGFILE} = 'lowercase.conf';
18
19ok($tf->start_proc == 0, "Starting lighttpd") or die();
20
21## check if lower-casing works
22
23$t->{REQUEST}  = ( <<EOF
24GET /image.JPG HTTP/1.0
25EOF
26 );
27$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
28ok($tf->handle_http($t) == 0, 'uppercase access');
29
30$t->{REQUEST}  = ( <<EOF
31GET /image.jpg HTTP/1.0
32EOF
33 );
34$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
35ok($tf->handle_http($t) == 0, 'lowercase access');
36
37## check that mod-auth works
38
39$t->{REQUEST}  = ( <<EOF
40GET /image.JPG HTTP/1.0
41Host: lowercase-auth
42EOF
43 );
44$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ];
45ok($tf->handle_http($t) == 0, 'uppercase access');
46
47$t->{REQUEST}  = ( <<EOF
48GET /image.jpg HTTP/1.0
49Host: lowercase-auth
50EOF
51 );
52$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ];
53ok($tf->handle_http($t) == 0, 'lowercase access');
54
55
56## check that mod-staticfile exclude works
57$t->{REQUEST}  = ( <<EOF
58GET /image.JPG HTTP/1.0
59Host: lowercase-exclude
60EOF
61 );
62$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
63ok($tf->handle_http($t) == 0, 'upper case access to staticfile.exclude-extension');
64
65$t->{REQUEST}  = ( <<EOF
66GET /image.jpg HTTP/1.0
67Host: lowercase-exclude
68EOF
69 );
70$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
71ok($tf->handle_http($t) == 0, 'lowercase access');
72
73
74## check that mod-access exclude works
75$t->{REQUEST}  = ( <<EOF
76GET /image.JPG HTTP/1.0
77Host: lowercase-deny
78EOF
79 );
80$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
81ok($tf->handle_http($t) == 0, 'uppercase access to url.access-deny protected location');
82
83$t->{REQUEST}  = ( <<EOF
84GET /image.jpg HTTP/1.0
85Host: lowercase-deny
86EOF
87 );
88$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
89ok($tf->handle_http($t) == 0, 'lowercase access');
90
91
92
93ok($tf->stop_proc == 0, "Stopping lighttpd");
94
95