mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
test_auth: Add test for wrong auth.
This commit is contained in:
parent
7e60a9b731
commit
d39cc3849a
@ -35,9 +35,19 @@ class TestAuth(TestHelper):
|
||||
self.assertEqual(hdrs["Content-Length"], str(self.datalen))
|
||||
self.assertEqual(hdrs["Content-Type"], "image/jpeg")
|
||||
self.assertContains(hdrs["Server"], "darkhttpd/")
|
||||
assert body == self.data, [url, resp, status, hdrs, body]
|
||||
assert body == self.data, [self.url, resp, status, hdrs, body]
|
||||
self.assertEqual(body, self.data)
|
||||
|
||||
def test_wrong_auth(self):
|
||||
resp = self.get(self.url, req_hdrs={
|
||||
'Authorization':
|
||||
'Basic ' + base64.b64encode(b'myuser:wrongpass').decode('utf-8')})
|
||||
status, hdrs, body = parse(resp)
|
||||
self.assertContains(status, '401 Unauthorized')
|
||||
self.assertEqual(hdrs['WWW-Authenticate'],
|
||||
'Basic realm="User Visible Realm"')
|
||||
self.assertContains(hdrs['Server'], 'darkhttpd/')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user