From 81b1bcbd740701467b370e8892abe81cb40c6bc1 Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Thu, 1 Jan 2015 21:20:08 +1100 Subject: [PATCH] Test for unreadable directory (can't generate listing). --- devel/cover | 2 ++ devel/test.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/devel/cover b/devel/cover index 5e42800..221a958 100755 --- a/devel/cover +++ b/devel/cover @@ -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" diff --git a/devel/test.py b/devel/test.py index cdb0cff..d4ddcc5 100755 --- a/devel/test.py +++ b/devel/test.py @@ -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)