1
0
Fork 0

Unit tests and password validation code

* provide nose based unit test infrastructure (fixes #20)
 * create unit tests for gnuviechadmin.util.passwordutils
 * add password validation function to gnuviechadmin.util.passwordutils
   (fixes #19)
 * make new files PEP8 clean (addresses #18)


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@258 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2008-06-07 14:48:52 +00:00
parent 09180938f1
commit 065996e0df
5 changed files with 156 additions and 18 deletions

View file

@ -23,6 +23,9 @@
import crypt
import crack
import random
import logging
log = logging.getLogger(__name__)
_pwchars = []
for _pair in (('0', '9'), ('A', 'Z'), ('a', 'z')):
@ -59,7 +62,7 @@ def checkpassword(password):
try:
return crack.VeryFascistCheck(password)
except ValueError, ve:
print "Weak password:", ve
log.info("Weak password: %s", ve)
return None
@ -89,4 +92,8 @@ def get_pw_tuple(password = None):
return (password, md5_crypt_password(password))
# TODO: implement a is_password_valid(hash, password) function
def validate_password(hash, password):
"""Validates whether the given clear text password matches the
given hash value.
"""
return hash == crypt.crypt(password, hash)