def testGoodPassword(self): pw = 'good_password' assert len(AuthEncoding.listSchemes()) > 0 # At least one must exist! for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert AuthEncoding.is_encrypted(enc) assert not AuthEncoding.is_encrypted(pw)
def testGoodPassword(self): pw = 'good_password' assert len(AuthEncoding.listSchemes()) > 0 # At least one must exist! for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert AuthEncoding.is_encrypted(enc) assert not AuthEncoding.is_encrypted(pw)
def testBlankPassword(self): pw = '' for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert not AuthEncoding.pw_validate(enc, enc) assert not AuthEncoding.pw_validate(enc, 'xxx')
def testBlankPassword(self): pw = '' for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert not AuthEncoding.pw_validate(enc, enc) assert not AuthEncoding.pw_validate(enc, 'xxx')
def testLongPassword(self): pw = 'Pw' * 2000 for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert not AuthEncoding.pw_validate(enc, enc) assert not AuthEncoding.pw_validate(enc, 'xxx') if id != 'CRYPT': # crypt truncates passwords and would fail these tests. assert not AuthEncoding.pw_validate(enc, pw[:-2]) assert not AuthEncoding.pw_validate(enc, pw[2:])
def testBadPasword(self): pw = 'OK_pa55w0rd \n' for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert not AuthEncoding.pw_validate(enc, 'xxx') assert not AuthEncoding.pw_validate(enc, enc) if id != 'CRYPT': # crypt truncates passwords and would fail this test. assert not AuthEncoding.pw_validate(enc, pw[:-1]) assert not AuthEncoding.pw_validate(enc, pw[1:]) assert AuthEncoding.pw_validate(enc, pw)
def testLongPassword(self): pw = 'Pw' * 2000 for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert not AuthEncoding.pw_validate(enc, enc) assert not AuthEncoding.pw_validate(enc, 'xxx') if id != 'CRYPT': # crypt truncates passwords and would fail these tests. assert not AuthEncoding.pw_validate(enc, pw[:-2]) assert not AuthEncoding.pw_validate(enc, pw[2:])
def testBadPasword(self): pw = 'OK_pa55w0rd \n' for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert not AuthEncoding.pw_validate(enc, 'xxx') assert not AuthEncoding.pw_validate(enc, enc) if id != 'CRYPT': # crypt truncates passwords and would fail this test. assert not AuthEncoding.pw_validate(enc, pw[:-1]) assert not AuthEncoding.pw_validate(enc, pw[1:]) assert AuthEncoding.pw_validate(enc, pw)
def testLongPassword(self): pw = 'Pw' * 2000 for id in AuthEncoding.listSchemes(): enc = AuthEncoding.pw_encrypt(pw, id) assert enc != pw assert AuthEncoding.pw_validate(enc, pw) assert not AuthEncoding.pw_validate(enc, enc) assert not AuthEncoding.pw_validate(enc, 'xxx') if id not in ('CRYPT', 'BCRYPT'): # crypt truncates passwords and would fail these tests. # bcrypt works with password inputs where len(pw) <= 50 assert not AuthEncoding.pw_validate(enc, pw[:-2]), ( '%r Failed: %s %s' % (id, enc, pw[:-2]) ) assert not AuthEncoding.pw_validate(enc, pw[2:])
def register_once(cls): if identity not in set(AuthEncoding.listSchemes()): AuthEncoding.registerScheme(identity, cls()) return cls
def register_once(cls): if identity not in set(AuthEncoding.listSchemes()): AuthEncoding.registerScheme(identity, cls()) return cls