diff options
Diffstat (limited to 'wsgitools')
-rwxr-xr-x | wsgitools/digest.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py index bebb2e2..91ea8cf 100755 --- a/wsgitools/digest.py +++ b/wsgitools/digest.py @@ -22,6 +22,11 @@ def parse_digest_response(data, ret=dict()): {'foo': 'bar'} >>> sorted(parse_digest_response('foo="bar=qux",spam=egg').items()) [('foo', 'bar=qux'), ('spam', 'egg')] + >>> try: + ... parse_digest_response('spam') + ... except ValueError: + ... print "ValueError" + ValueError """ data = data.strip() key, rest = data.split('=', 1) # raises ValueError @@ -129,6 +134,17 @@ class StatelessNonceStore(NonceStoreBase): nonces. This nonce store is usable with L{scgi.forkpool}. + + >>> s = StatelessNonceStore() + >>> n = s.newnonce() + >>> s.checknonce("spam") + False + >>> s.isnonce(n) + True + >>> s.checknonce(n) + True + >>> s.checknonce(n) + True """ def __init__(self, maxage=300, secret=None): """ @@ -206,7 +222,20 @@ class StatelessNonceStore(NonceStoreBase): __all__.append("MemoryNonceStore") class MemoryNonceStore(NonceStoreBase): - """Simple in-memory mechanism to store nonces.""" + """ + Simple in-memory mechanism to store nonces. + + >>> s = MemoryNonceStore(maxuses=1) + >>> n = s.newnonce() + >>> s.checknonce("spam") + False + >>> s.isnonce(n) + True + >>> s.checknonce(n) + True + >>> s.checknonce(n) + False + """ def __init__(self, maxage=300, maxuses=5): """ @type maxage: int |