diff options
author | root <root@rbsd.ankarstrom.se> | 2021-04-25 17:55:02 +0000 |
---|---|---|
committer | root <root@rbsd.ankarstrom.se> | 2021-04-25 17:55:02 +0000 |
commit | e0778a8e6ec87b34077776a72f01f4d0305ae7e2 (patch) | |
tree | 9749afc138f18ec175db85b8fce154b11db4bb0c /t | |
parent | 9bf20db492de868e30079a41cc2bddad7ba5ecb4 (diff) | |
download | Apache-Inject-e0778a8e6ec87b34077776a72f01f4d0305ae7e2.tar.gz |
Re-arrange tests
Diffstat (limited to 't')
-rw-r--r-- | t/basic.t | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -11,6 +11,8 @@ my $head; # expected page header my $foot; # expected page footer my @body; # sections of page body +mkdir 't/htdocs/subdir' if ! -d 't/htdocs/subdir'; + # Read contents of header and footer open my $h, '<', 't/htdocs/head.html' @@ -33,12 +35,17 @@ sub set { # Run tests set 't/htdocs/.htaccess', <<CONF; -Inject head.html foot.html +Inject " " CONF -mkdir 't/htdocs/subdir' if ! -d 't/htdocs/subdir'; -set 't/htdocs/subdir/.htaccess', <<CONF; -Inject head.html +@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; +Inject head.html foot.html CONF @body = ("<title>Test</title>\n", "This is a test page.\n"); @@ -51,6 +58,15 @@ set '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; +Inject head.html +CONF + +@body = ("This is a test page.\n"); +set '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; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", @@ -66,19 +82,6 @@ set 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<!doctype> with leading newline'; -@body = ("This is a test page.\n"); -set 't/htdocs/subdir/test.html', @body; -ok GET_BODY('/subdir/test.html'), "$head${body[0]}", - 'different injection in subdirectory'; - -set 't/htdocs/subdir/.htaccess', <<CONF; -Inject " " -CONF - -set 't/htdocs/ ', 'head'; # needed in case " " is (incorrectly) accepted -ok GET_BODY('/subdir/test.html') eq "head${body[0]}" && 1 || 0, 0, - 'single-space argument should fail'; - unlink 't/htdocs/.htaccess'; unlink 't/htdocs/test.html'; unlink 't/htdocs/subdir/.htaccess'; |