mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Test 404 and 403.
This commit is contained in:
@@ -73,6 +73,20 @@ class TestHelper(unittest.TestCase):
|
||||
"You requested an invalid URL: %s\n"%path,
|
||||
'Generated by darkhttpd')
|
||||
|
||||
def assertNotFound(self, body, path):
|
||||
self.assertContains(body,
|
||||
"<title>404 Not Found</title>",
|
||||
"<h1>Not Found</h1>\n",
|
||||
"The URL you requested (%s) was not found.\n"%path,
|
||||
'Generated by darkhttpd')
|
||||
|
||||
def assertForbidden(self, body, path):
|
||||
self.assertContains(body,
|
||||
"<title>403 Forbidden</title>",
|
||||
"<h1>Forbidden</h1>\n",
|
||||
"You don't have permission to access (%s).\n"%path,
|
||||
'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})
|
||||
@@ -159,6 +173,8 @@ def setUpModule():
|
||||
["no leading slash", "dir/../", "assertIsInvalid"],
|
||||
["invalid up dir", "/../", "assertIsInvalid"],
|
||||
["fancy invalid up dir", "/./dir/./../../", "assertIsInvalid"],
|
||||
["not found", "/not_found.txt", "assertNotFound"],
|
||||
["forbidden", "/forbidden/x", "assertForbidden"],
|
||||
]:
|
||||
makeSimpleCases(*args)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user