diff options
author | Helmut Grohne <helmut@subdivi.de> | 2011-11-02 19:24:44 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2011-11-02 19:24:44 +0100 |
commit | 8cebeca5b363b363e101a986d6be089b3429bf08 (patch) | |
tree | 96d8a140bbe25fccbb5527e6813e802c9de7c0a0 | |
parent | c5294defb25246d01c04462ce089a11b1c7c0c2d (diff) | |
download | wsgitools-8cebeca5b363b363e101a986d6be089b3429bf08.tar.gz |
added digest auth test with qop=auth
-rwxr-xr-x | test.py | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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: |