Skip to content

Commit 58d9369

Browse files
committed
windows: Fix failing password tests due to missing crypt module
1 parent bd87571 commit 58d9369

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

roundup/password.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def h64decode(data):
4545
if off == 0:
4646
return b64decode(data, "./")
4747
elif off == 1:
48-
raise ValueError("invalid bas64 input")
48+
raise ValueError("Invalid base64 input")
4949
elif off == 2:
5050
return b64decode(data + "==", "./")
5151
else:
@@ -162,7 +162,7 @@ def encodePassword(plaintext, scheme, other=None, config=None):
162162
elif scheme == 'plaintext':
163163
s = plaintext
164164
else:
165-
raise PasswordValueError, 'unknown encryption scheme %r'%scheme
165+
raise PasswordValueError, 'Unknown encryption scheme %r'%scheme
166166
return s
167167

168168
def generatePassword(length=8):
@@ -275,7 +275,7 @@ def unpack(self, encrypted, scheme=None, strict=False, config=None):
275275
# currently plaintext - encrypt
276276
self.setPassword(encrypted, scheme, config=config)
277277
if strict and self.scheme not in self.known_schemes:
278-
raise PasswordValueError, "unknown encryption scheme: %r" % (self.scheme,)
278+
raise PasswordValueError, "Unknown encryption scheme: %r" % (self.scheme,)
279279

280280
def setPassword(self, plaintext, scheme=None, config=None):
281281
"""Sets encrypts plaintext."""
@@ -307,11 +307,12 @@ def test():
307307
assert 'not sekrit' != p
308308

309309
# crypt
310-
p = Password('sekrit', 'crypt')
311-
assert p == 'sekrit'
312-
assert p != 'not sekrit'
313-
assert 'sekrit' == p
314-
assert 'not sekrit' != p
310+
if crypt: # not available on Windows
311+
p = Password('sekrit', 'crypt')
312+
assert p == 'sekrit'
313+
assert p != 'not sekrit'
314+
assert 'sekrit' == p
315+
assert 'not sekrit' != p
315316

316317
# PBKDF2 - low level function
317318
from binascii import unhexlify

test/test_cgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def testPasswordConfigOption(self):
459459
form = dict(__login_name='Chef', __login_password='foo')
460460
cl = self._make_client(form)
461461
self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS = 1000
462-
pw1 = password.Password('foo', scheme='crypt')
462+
pw1 = password.Password('foo', scheme='MD5')
463463
self.assertEqual(pw1.needs_migration(), True)
464464
self.db.user.set(chef, password=pw1)
465465
self.db.commit()

0 commit comments

Comments
 (0)