@@ -421,13 +421,13 @@ def __str__(self):
421421 return '{%s}%s' % (self .scheme , self .password )
422422
423423
424- def test_missing_crypt ():
424+ def test_missing_crypt (config = None ):
425425 p = encodePassword ('sekrit' , 'crypt' ) # noqa: F841 - test only
426426
427427
428- def test ():
428+ def test (config = None ):
429429 # SHA
430- p = Password ('sekrit' )
430+ p = Password ('sekrit' , config = config )
431431 assert Password (encrypted = str (p )) == 'sekrit'
432432 assert 'sekrit' == Password (encrypted = str (p ))
433433 assert p == 'sekrit'
@@ -436,7 +436,7 @@ def test():
436436 assert 'not sekrit' != p
437437
438438 # MD5
439- p = Password ('sekrit' , 'MD5' )
439+ p = Password ('sekrit' , 'MD5' , config = config )
440440 assert Password (encrypted = str (p )) == 'sekrit'
441441 assert 'sekrit' == Password (encrypted = str (p ))
442442 assert p == 'sekrit'
@@ -446,7 +446,7 @@ def test():
446446
447447 # crypt
448448 if crypt : # not available on Windows
449- p = Password ('sekrit' , 'crypt' )
449+ p = Password ('sekrit' , 'crypt' , config = config )
450450 assert Password (encrypted = str (p )) == 'sekrit'
451451 assert 'sekrit' == Password (encrypted = str (p ))
452452 assert p == 'sekrit'
@@ -455,7 +455,7 @@ def test():
455455 assert 'not sekrit' != p
456456
457457 # SSHA
458- p = Password ('sekrit' , 'SSHA' )
458+ p = Password ('sekrit' , 'SSHA' , config = config )
459459 assert Password (encrypted = str (p )) == 'sekrit'
460460 assert 'sekrit' == Password (encrypted = str (p ))
461461 assert p == 'sekrit'
@@ -473,7 +473,7 @@ def test():
473473 assert encodePassword ("sekrit" , "PBKDF2" , h ) == h
474474
475475 # PBKDF2 - high level integration
476- p = Password ('sekrit' , 'PBKDF2' )
476+ p = Password ('sekrit' , 'PBKDF2' , config = config )
477477 assert Password (encrypted = str (p )) == 'sekrit'
478478 assert 'sekrit' == Password (encrypted = str (p ))
479479 assert p == 'sekrit'
@@ -483,7 +483,15 @@ def test():
483483
484484
485485if __name__ == '__main__' :
486- test ()
487- test_missing_crypt ()
486+ from roundup .configuration import CoreConfig
487+ test (CoreConfig ())
488+ crypt = None
489+ exception = None
490+ try :
491+ test_missing_crypt (CoreConfig ())
492+ except PasswordValueError as e :
493+ exception = e
494+ assert exception != None
495+ assert exception .__str__ () == "Unsupported encryption scheme 'crypt'"
488496
489497# vim: set filetype=python sts=4 sw=4 et si :
0 commit comments