diff --git a/devel/test_auth.py b/devel/test_auth.py index a071b7a..c8ad94d 100755 --- a/devel/test_auth.py +++ b/devel/test_auth.py @@ -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()