Skip to content

Commit

Permalink
Update several tests to cover the unicode hash input case better, and…
Browse files Browse the repository at this point in the history
… update the description of the salt-means-random-output test for SSHA.
  • Loading branch information
Martijn Pieters committed Feb 20, 2011
1 parent e85cdcc commit 2b3987e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/zope/password/password.py
Expand Up @@ -127,6 +127,9 @@ class SSHAPasswordManager(PlainTextPasswordManager):
>>> 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
Expand Down Expand Up @@ -207,6 +210,14 @@ class MD5PasswordManager(PlainTextPasswordManager):
>>> 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
Expand Down Expand Up @@ -270,6 +281,14 @@ class SHA1PasswordManager(PlainTextPasswordManager):
>>> 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
Expand Down

0 comments on commit 2b3987e

Please sign in to comment.