summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarix <darix@152afb58-edef-0310-8abb-c4023f1b3aa9>2006-09-07 11:33:21 +0000
committerdarix <darix@152afb58-edef-0310-8abb-c4023f1b3aa9>2006-09-07 11:33:21 +0000
commit911c10769035a3b2fa1742cc2b22d5d53a4d4423 (patch)
tree5e4e476cf9a02fa0b28f7cc5964d143e96589578
parent488cce8252ef80d4e31d5516db3248d0c24750a6 (diff)
downloadlighttpd-911c10769035a3b2fa1742cc2b22d5d53a4d4423.tar.gz
- added missing file symlink.t
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.11-ssl-fixes@1284 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--tests/symlink.t115
1 files changed, 115 insertions, 0 deletions
diff --git a/tests/symlink.t b/tests/symlink.t
new file mode 100644
index 00000000..fd7b5059
--- /dev/null
+++ b/tests/symlink.t
@@ -0,0 +1,115 @@
+#!/usr/bin/env perl
+BEGIN {
+ # add current source dir to the include-path
+ # we need this for make distcheck
+ (my $srcdir = $0) =~ s#/[^/]+$#/#;
+ unshift @INC, $srcdir;
+}
+
+use strict;
+use IO::Socket;
+use Test::More tests => 10;
+use LightyTest;
+
+my $tf = LightyTest->new();
+my $t;
+my $docroot = "$tf->{'SRCDIR'}/tmp/lighttpd/servers/www.example.org/pages/";
+
+sub init_testbed {
+ return 0 unless eval { symlink("",""); 1 };
+ my $f = "$docroot/index.html";
+ my $l = "$docroot/index.xhtml";
+ my $rc = undef;
+ unless (-l $l) {
+ return 0 unless symlink($f,$l);
+ };
+ $f = "$docroot/expire";
+ $l = "$docroot/symlinked";
+ $rc = undef;
+ unless (-l $l) {
+ return 0 unless symlink($f,$l);
+ };
+ return 1;
+};
+
+SKIP: {
+ skip "perl does not support symlinking or setting up the symlinks failed.", 10 unless init_testbed;
+ ok($tf->start_proc == 0, "Starting lighttpd") or die();
+
+# allow case
+# simple file
+ $t->{REQUEST} = ( <<EOF
+GET /index.html HTTP/1.0
+Host: symlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ ok($tf->handle_http($t) == 0, 'allow: simple file');
+
+# symlinked file
+ $t->{REQUEST} = ( <<EOF
+GET /index.xhtml HTTP/1.0
+Host: symlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ ok($tf->handle_http($t) == 0, 'allow: symlinked file');
+
+# directly symlinked dir
+ $t->{REQUEST} = ( <<EOF
+GET /symlinked/ HTTP/1.0
+Host: symlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ ok($tf->handle_http($t) == 0, 'allow: directly symlinked dir');
+
+# symlinked dir in path
+ $t->{REQUEST} = ( <<EOF
+GET /symlinked/access.txt HTTP/1.0
+Host: symlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ ok($tf->handle_http($t) == 0, 'allow: symlinked dir in path');
+
+# deny case
+# simple file
+ $t->{REQUEST} = ( <<EOF
+GET /index.html HTTP/1.0
+Host: nosymlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
+ ok($tf->handle_http($t) == 0, 'deny: simple file');
+
+# symlinked file
+ $t->{REQUEST} = ( <<EOF
+GET /index.xhtml HTTP/1.0
+Host: nosymlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ ok($tf->handle_http($t) == 0, 'deny: symlinked file');
+
+# directly symlinked dir
+ $t->{REQUEST} = ( <<EOF
+GET /symlinked/ HTTP/1.0
+Host: nosymlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ ok($tf->handle_http($t) == 0, 'deny: directly symlinked dir');
+
+# symlinked dir in path
+ $t->{REQUEST} = ( <<EOF
+GET /symlinked/access.txt HTTP/1.0
+Host: nosymlink.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
+ ok($tf->handle_http($t) == 0, 'deny: symlinked dir in path');
+
+# cleanup
+ ok($tf->stop_proc == 0, "Stopping lighttpd");
+};