aboutsummaryrefslogtreecommitdiff
path: root/t/basic.t
diff options
context:
space:
mode:
authorroot <root@rbsd.ankarstrom.se>2021-04-26 12:26:06 +0000
committerroot <root@rbsd.ankarstrom.se>2021-04-26 12:26:06 +0000
commite1c7d5442ca1d3bd67c200d2dbd94bd0e40e72bd (patch)
treefe2b3bb1c7e3612f05311d591f3704deb912fcd4 /t/basic.t
parente455862603e1ae1842b26bc9cbe685e5c4ee2d90 (diff)
downloadApache-Inject-e1c7d5442ca1d3bd67c200d2dbd94bd0e40e72bd.tar.gz
Use single hyphen for NULL value, allow the user to specify it
This lets the user inject a footer without injecting a header.
Diffstat (limited to 't/basic.t')
-rw-r--r--t/basic.t40
1 files changed, 20 insertions, 20 deletions
diff --git a/t/basic.t b/t/basic.t
index c607548..f81c661 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -7,6 +7,8 @@ use Apache::TestRequest qw/GET_BODY/;
BEGIN { plan tests => 7; }
+# Prepare environment
+
my $head; # expected page header
my $foot; # expected page footer
my @body; # sections of page body
@@ -25,7 +27,7 @@ close $h; close $f;
# Helper for replacing file contents
-sub set {
+sub overwrite {
my $file = shift;
open my $fh, '>', $file or die "Could not open > $file: $!";
print $fh join('', @_);
@@ -34,56 +36,54 @@ sub set {
# Run tests
-set 't/htdocs/.htaccess', <<CONF;
-Inject " "
-CONF
-
-@body = ("This is a test page.\n");
-set 't/htdocs/test.html', @body;
-set 't/htdocs/ ', 'whatever';
-ok GET_BODY('/test.html'), ${body[0]}, # should not include 'whatever'
- 'single-space argument should fail';
-
-set 't/htdocs/.htaccess', <<CONF;
+overwrite 't/htdocs/.htaccess', <<CONF;
Inject head.html foot.html
CONF
@body = ("<title>Test</title>\n", "This is a test page.\n");
-set 't/htdocs/test.html', @body;
+overwrite 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<head>-less head';
@body = ("<head>...</head>\n", "This is a test page.\n");
-set 't/htdocs/test.html', @body;
+overwrite 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<head>-ful head';
-set 't/htdocs/subdir/.htaccess', <<CONF;
+overwrite 't/htdocs/subdir/.htaccess', <<CONF;
Inject head.html
CONF
@body = ("This is a test page.\n");
-set 't/htdocs/subdir/test.html', @body;
+overwrite 't/htdocs/subdir/test.html', @body;
ok GET_BODY('/subdir/test.html'), "$head${body[0]}",
'different injection in subdirectory';
@body = ("<html>\n", "This is a test page.\n", "</html>\n");
-set 't/htdocs/test.html', @body;
+overwrite 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}",
'<html>-wrapped document';
@body = ("<!doctype html>\n", "This is a test page.\n");
-set 't/htdocs/test.html', @body;
+overwrite 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<!doctype>';
@body = ("\n<!doctype html>\n", "This is a test page.\n");
-set 't/htdocs/test.html', @body;
+overwrite 't/htdocs/test.html', @body;
ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot",
'<!doctype> with leading newline';
+overwrite 't/htdocs/.htaccess', <<CONF;
+Inject - head.html
+CONF
+
+@body = ("This is a test page.\n");
+overwrite 't/htdocs/test.html', @body;
+ok GET_BODY('/test.html'), "${body[0]}$head",
+ 'only footer';
+
unlink 't/htdocs/.htaccess';
unlink 't/htdocs/test.html';
unlink 't/htdocs/subdir/.htaccess';
unlink 't/htdocs/subdir/test.html';
-unlink 't/htdocs/ ';