Test 404 and 403.

This commit is contained in:
Emil Mikulic
2015-01-01 20:32:52 +11:00
parent 456bbfcde6
commit 946a910935
2 changed files with 20 additions and 2 deletions

View File

@@ -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)