From 8cebeca5b363b363e101a986d6be089b3429bf08 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 2 Nov 2011 19:24:44 +0100 Subject: added digest auth test with qop=auth --- test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test.py') diff --git a/test.py b/test.py index c9d972d..3c77c06 100755 --- a/test.py +++ b/test.py @@ -218,6 +218,21 @@ class AuthDigestMiddlewareTest(unittest.TestCase): def test401authfail(self): self.doauth(password="spam", status=401) + def testqopauth(self): + res = self.req(self.app) + nonce = next(iter(filter(lambda x: x.startswith("nonce="), + res.getheader("WWW-Authenticate").split()))) + nonce = nonce.split('"')[1] + req = self.req.copy() + token = md5("bar:foo:baz").hexdigest() + other = md5("GET:").hexdigest() + resp = md5("%s:%s:1:qux:auth:%s" % (token, nonce, other)).hexdigest() + req.setheader('http-authorization', 'Digest algorithm=md5,nonce="%s",' \ + 'uri=,username=bar,response="%s",qop=auth,nc=1,' \ + 'cnonce=qux' % (nonce, resp)) + res = req(self.app) + res.status(200) + from wsgitools import middlewares class StupidIO: -- cgit v1.2.3