You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.9 KiB

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