summaryrefslogtreecommitdiff
path: root/wsgitools
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
parent0c93b64584c7067d7a5f6876ded2a59ad021d3bc (diff)
downloadwsgitools-cc28226b4afcd1803c9790e8ba238e2125ce0129.tar.gz
add more assertions for types of passed parameters
Diffstat (limited to 'wsgitools')
-rw-r--r--wsgitools/digest.py7
-rw-r--r--wsgitools/filters.py2
2 files changed, 9 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:
diff --git a/wsgitools/filters.py b/wsgitools/filters.py
index 1c3fadc..e455cbe 100644
--- a/wsgitools/filters.py
+++ b/wsgitools/filters.py
@@ -238,6 +238,7 @@ class RequestLogWSGIFilter(BaseWSGIFilter):
"""
BaseWSGIFilter.__init__(self)
assert hasattr(log, "write")
+ assert hasattr(log, "flush") or not flush
self.log = log
self.flush = flush
self.remote = "?"
@@ -279,6 +280,7 @@ class RequestLogWSGIFilter(BaseWSGIFilter):
@type data: str
@rtype: str
"""
+ assert isinstance(data, str)
self.length += len(data)
return data
def handle_close(self):