From 19b6693b552b84f92823a26b85abb765c280aed2 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 8 Jun 2011 10:20:02 +0200 Subject: more testcases --- test.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test.py') diff --git a/test.py b/test.py index 92e2ce9..c9d972d 100755 --- a/test.py +++ b/test.py @@ -184,6 +184,20 @@ class AuthDigestMiddlewareTest(unittest.TestCase): res.status(401) res.header("WWW-Authenticate", lambda _: True) + def test401garbage(self): + req = self.req.copy() + req.setheader('http-authorization', 'Garbage') + res = req(self.app) + res.status(401) + res.header("WWW-Authenticate", lambda _: True) + + def test401digestgarbage(self): + req = self.req.copy() + req.setheader('http-authorization', 'Digest ","') + res = req(self.app) + res.status(401) + res.header("WWW-Authenticate", lambda _: True) + def doauth(self, password="baz", status=200): res = self.req(self.app) nonce = next(iter(filter(lambda x: x.startswith("nonce="), @@ -258,6 +272,20 @@ class BasicAuthMiddlewareTest(unittest.TestCase): res.status(401) res.header("WWW-Authenticate", lambda _: True) + def test401garbage(self): + req = self.req.copy() + req.setheader('http-authorization', 'Garbage') + res = req(self.app) + res.status(401) + res.header("WWW-Authenticate", lambda _: True) + + def test401basicgarbage(self): + req = self.req.copy() + req.setheader('http-authorization', 'Basic ()') + res = req(self.app) + res.status(401) + res.header("WWW-Authenticate", lambda _: True) + def doauth(self, password="baz", status=200): req = self.req.copy() token = ("bar:%s" % password).encode("base64").strip() -- cgit v1.2.3