aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@rbsd.ankarstrom.se>2021-04-24 14:20:56 +0000
committerroot <root@rbsd.ankarstrom.se>2021-04-24 14:20:56 +0000
commit0cbcdb0d4083eb97a6e052471cb51f8b31f3c92c (patch)
tree9cdb02a2b70d23d746ab5453de3259e0defa2d68
parent0c0554d767a6cb97c58c3ca7b639f3070e5591f5 (diff)
downloadApache-Inject-0cbcdb0d4083eb97a6e052471cb51f8b31f3c92c.tar.gz
Improve testing capabilities
-rw-r--r--t/basic.t65
-rw-r--r--t/conf/extra.conf.in4
-rw-r--r--t/conf/extra.last.conf.in3
3 files changed, 44 insertions, 28 deletions
diff --git a/t/basic.t b/t/basic.t
index 4833d68..c82f6e2 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -7,46 +7,61 @@ use Apache::TestRequest qw/GET_BODY/;
plan tests => 5;
-# Prepare environment
+my $head; # expected page header
+my $foot; # expected page footer
+my @body; # sections of page body
-open my $h, '<', 't/htdocs/head.html' or die;
-open my $f, '<', 't/htdocs/foot.html' or die;
-my $head = do { local $/; <$h> };
-my $foot = do { local $/; <$f> };
+# Read contents of header and footer
+
+open my $h, '<', 't/htdocs/head.html' or die "Could not open < head.html: $!";
+open my $f, '<', 't/htdocs/foot.html' or die "Could not open < foot.html: $!";
+$head = do { local $/; <$h> };
+$foot = do { local $/; <$f> };
close $h; close $f;
-my @test;
-sub prepare {
- open my $t, '>', 't/htdocs/test.html' or die;
- print $t join('', @_);
- close $t;
+# Set up helpers
+
+sub set_conf {
+ open my $c, '>', 't/htdocs/.htaccess' or die;
+ print $c shift;
+ close $c;
+}
+sub set_body {
+ open my $b, '>', 't/htdocs/test.html' or die;
+ print $b join('', @_);
+ close $b;
}
# Run tests
-@test = ("<title>Test</title>\n", "This is a test page.\n");
-prepare @test;
-ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+set_conf <<CONF;
+Inject head.html foot.html
+CONF
+
+@body = ("<title>Test</title>\n", "This is a test page.\n");
+set_body @body;
+ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<head>-less head';
-@test = ("<head>...</head>\n", "This is a test page.\n");
-prepare @test;
-ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+@body = ("<head>...</head>\n", "This is a test page.\n");
+set_body @body;
+ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<head>-ful head';
-@test = ("<html>\n", "This is a test page.\n", "</html>\n");
-prepare @test;
-ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot${test[2]}",
+@body = ("<html>\n", "This is a test page.\n", "</html>\n");
+set_body @body;
+ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}",
'<html>-wrapped document';
-@test = ("<!doctype html>\n", "This is a test page.\n");
-prepare @test;
-ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+@body = ("<!doctype html>\n", "This is a test page.\n");
+set_body @body;
+ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<!doctype>';
-@test = ("\n<!doctype html>\n", "This is a test page.\n");
-prepare @test;
-ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+@body = ("\n<!doctype html>\n", "This is a test page.\n");
+set_body @body;
+ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<!doctype> with leading newline';
+unlink 't/htdocs/.htaccess';
unlink 't/htdocs/test.html';
diff --git a/t/conf/extra.conf.in b/t/conf/extra.conf.in
index fe9de1d..1a9ce52 100644
--- a/t/conf/extra.conf.in
+++ b/t/conf/extra.conf.in
@@ -1 +1,5 @@
PerlSwitches -I@ServerRoot@/../lib
+<Directory />
+ Options FollowSymLinks
+ AllowOverride All
+</Directory>
diff --git a/t/conf/extra.last.conf.in b/t/conf/extra.last.conf.in
index 0156023..b708606 100644
--- a/t/conf/extra.last.conf.in
+++ b/t/conf/extra.last.conf.in
@@ -1,4 +1 @@
PerlLoadModule Apache::Inject
-<FilesMatch ".*\.html">
- Inject head.html foot.html
-</FilesMatch>