Test for unreadable directory (can't generate listing).
authorEmil Mikulic <emikulic@gmail.com>
Thu, 1 Jan 2015 10:20:08 +0000 (21:20 +1100)
committerEmil Mikulic <emikulic@gmail.com>
Thu, 1 Jan 2015 10:20:08 +0000 (21:20 +1100)
devel/cover
devel/test.py

index 5e42800..221a958 100755 (executable)
@@ -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"
index cdb0cff..d4ddcc5 100755 (executable)
@@ -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)