[Checkins] SVN: zope.password/trunk/src/zope/password/password.py Update several tests to cover the unicode hash input case better, and update the description of the salt-means-random-output test for SSHA.

Martijn Pieters mj at zopatista.com
Sun Feb 20 16:45:30 EST 2011


Log message for revision 120477:
  Update several tests to cover the unicode hash input case better, and update the description of the salt-means-random-output test for SSHA.

Changed:
  U   zope.password/trunk/src/zope/password/password.py

-=-
Modified: zope.password/trunk/src/zope/password/password.py
===================================================================
--- zope.password/trunk/src/zope/password/password.py	2011-02-20 21:15:53 UTC (rev 120476)
+++ zope.password/trunk/src/zope/password/password.py	2011-02-20 21:45:29 UTC (rev 120477)
@@ -127,6 +127,9 @@
     >>> manager.checkPassword(encoded, password + u"wrong")
     False
 
+    Because a random salt is generated, the output of encodePassword is
+    different every time you call it.
+
     >>> manager.encodePassword(password) != manager.encodePassword(password)
     True
 
@@ -207,6 +210,14 @@
     >>> manager.encodePassword('secret')
     '{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ=='
 
+    The password manager should be able to cope with unicode strings for input::
+
+    >>> passwd = u'foobar\u2211' # sigma-sign.
+    >>> manager.checkPassword(manager.encodePassword(passwd), passwd)
+    True
+    >>> manager.checkPassword(unicode(manager.encodePassword(passwd)), passwd)
+    True
+
     A previous version of this manager also created a cosmetic salt, added
     to the start of the hash, but otherwise not used in creating the hash
     itself. Moreover, it generated the MD5 hash as a hex digest, not a base64
@@ -270,6 +281,14 @@
     >>> manager.encodePassword('secret')
     '{SHA}5en6G6MezRroT3XKqkdPOmY/BfQ='
 
+    The password manager should be able to cope with unicode strings for input::
+
+    >>> passwd = u'foobar\u2211' # sigma-sign.
+    >>> manager.checkPassword(manager.encodePassword(passwd), passwd)
+    True
+    >>> manager.checkPassword(unicode(manager.encodePassword(passwd)), passwd)
+    True
+
     A previous version of this manager also created a cosmetic salt, added
     to the start of the hash, but otherwise not used in creating the hash
     itself. Moreover, it generated the SHA hash as a hex digest, not a base64



More information about the checkins mailing list