Test for unreadable directory (can't generate listing).

This commit is contained in:
Emil Mikulic 2015-01-01 21:20:08 +11:00
parent d5bd7558f4
commit 81b1bcbd74
2 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,8 @@ fi
mkdir $DIR || exit 1
mkdir $DIR/forbidden || exit 1
chmod 0 $DIR/forbidden || exit 1
mkdir $DIR/unreadable || exit 1
chmod 0100 $DIR/unreadable || exit 1
rm -f darkhttpd.gcda darkhttpd.log
echo "===> test_make_safe_uri"

View File

@ -87,6 +87,11 @@ class TestHelper(unittest.TestCase):
"You don't have permission to access (%s).\n"%path,
'Generated by darkhttpd')
def assertUnreadable(self, body, path):
self.assertContains(body,
"Couldn't list directory: Permission denied\n",
'Generated by darkhttpd')
def drive_range(self, range_in, range_out, len_out, data_out,
status_out = "206 Partial Content"):
resp = Conn().get(self.url, req_hdrs = {"Range": "bytes="+range_in})
@ -175,6 +180,7 @@ def setUpModule():
["fancy invalid up dir", "/./dir/./../../", "assertIsInvalid"],
["not found", "/not_found.txt", "assertNotFound"],
["forbidden", "/forbidden/x", "assertForbidden"],
["unreadable", "/unreadable/", "assertUnreadable"],
]:
makeSimpleCases(*args)