1"""tests for passlib.win32 -- (c) Assurance Technologies 2003-2009""" 2#============================================================================= 3# imports 4#============================================================================= 5# core 6import warnings 7# site 8# pkg 9from passlib.tests.utils import TestCase 10# module 11from passlib.utils.compat import u 12 13#============================================================================= 14# 15#============================================================================= 16class UtilTest(TestCase): 17 """test util funcs in passlib.win32""" 18 19 ##test hashes from http://msdn.microsoft.com/en-us/library/cc245828(v=prot.10).aspx 20 ## among other places 21 22 def setUp(self): 23 super(UtilTest, self).setUp() 24 warnings.filterwarnings("ignore", 25 "the 'passlib.win32' module is deprecated") 26 27 def test_lmhash(self): 28 from passlib.win32 import raw_lmhash 29 for secret, hash in [ 30 ("OLDPASSWORD", u("c9b81d939d6fd80cd408e6b105741864")), 31 ("NEWPASSWORD", u('09eeab5aa415d6e4d408e6b105741864')), 32 ("welcome", u("c23413a8a1e7665faad3b435b51404ee")), 33 ]: 34 result = raw_lmhash(secret, hex=True) 35 self.assertEqual(result, hash) 36 37 def test_nthash(self): 38 warnings.filterwarnings("ignore", 39 r"nthash\.raw_nthash\(\) is deprecated") 40 from passlib.win32 import raw_nthash 41 for secret, hash in [ 42 ("OLDPASSWORD", u("6677b2c394311355b54f25eec5bfacf5")), 43 ("NEWPASSWORD", u("256781a62031289d3c2c98c14f1efc8c")), 44 ]: 45 result = raw_nthash(secret, hex=True) 46 self.assertEqual(result, hash) 47 48#============================================================================= 49# eof 50#============================================================================= 51