summaryrefslogtreecommitdiff
path: root/wsgitools/digest.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2011-07-24 22:43:26 +0200
committerHelmut Grohne <helmut@subdivi.de>2011-07-24 22:43:26 +0200
commitcc28226b4afcd1803c9790e8ba238e2125ce0129 (patch)
tree0a12bbadafd0f52fc0693c1d80753815c86b79b4 /wsgitools/digest.py
parent0c93b64584c7067d7a5f6876ded2a59ad021d3bc (diff)
downloadwsgitools-cc28226b4afcd1803c9790e8ba238e2125ce0129.tar.gz
add more assertions for types of passed parameters
Diffstat (limited to 'wsgitools/digest.py')
-rw-r--r--wsgitools/digest.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py
index 4b7dd96..86de17e 100644
--- a/wsgitools/digest.py
+++ b/wsgitools/digest.py
@@ -61,6 +61,7 @@ def parse_digest_response(data, ret=None):
... print("ValueError")
ValueError
"""
+ assert isinstance(data, str)
if ret is None:
ret = {}
data = data.strip()
@@ -100,6 +101,7 @@ class AbstractTokenGenerator:
"""
@type realm: str
"""
+ assert isinstance(realm, str)
self.realm = realm
def __call__(self, username, algo="md5"):
@@ -126,6 +128,8 @@ class AbstractTokenGenerator:
@param environ: ignored
@rtype: bool
"""
+ assert isinstance(username, str)
+ assert isinstance(password, str)
token = md5("%s:%s:%s" % (username, self.realm, password)).hexdigest()
return token == self(username)
@@ -147,6 +151,7 @@ class AuthTokenGenerator(AbstractTokenGenerator):
self.getpass = getpass
def __call__(self, username, algo="md5"):
+ assert isinstance(username, str)
assert algo.lower() in ["md5", "md5-sess"]
password = self.getpass(username)
if password is None:
@@ -180,6 +185,7 @@ class HtdigestTokenGenerator(AbstractTokenGenerator):
@raises IOError:
@raises ValueError:
"""
+ assert isinstance(htdigestfile, str)
self.users = {}
for line in file(htdigestfile):
parts = line.rstrip("\n").split(":")
@@ -204,6 +210,7 @@ class UpdatingHtdigestTokenGenerator(HtdigestTokenGenerator):
for changes on each invocation.
"""
def __init__(self, realm, htdigestfile, ignoreparseerrors=False):
+ assert isinstance(htdigestfile, str)
try:
self.statcache = os.stat(htdigestfile)
except OSError, err: