def test_empty_password(self): profile = UserProfile(password=None) assert profile.has_usable_password() is False assert not check_password(None, profile.password) assert not profile.check_password(None) profile = UserProfile(password='') assert profile.has_usable_password() is False assert not check_password('', profile.password) assert not profile.check_password('')
def test_empty_password(self): profile = UserProfile(password=None) assert profile.has_usable_password() is False assert not check_password(None, profile.password) assert not profile.check_password(None) profile = UserProfile(password='') assert profile.has_usable_password() is False assert not check_password('', profile.password) assert not profile.check_password('')
def test_persona_sha512_base64_maybe_not_latin1(self): passwd = u'fo\xf3' hsh = hashlib.sha512(self.bytes_ + passwd.encode('latin1')).hexdigest() u = UserProfile(password='******' % (encodestring(self.bytes_), hsh)) assert u.check_password(self.utf) is False assert u.has_usable_password() is True
def test_persona_sha512_md5_base64(self): md5 = hashlib.md5('password').hexdigest() hsh = hashlib.sha512(self.bytes_ + md5).hexdigest() u = UserProfile(password='******' % (encodestring(self.bytes_), hsh)) assert u.check_password('password') is True assert u.has_usable_password() is True
def test_persona_sha512_base64_maybe_not_latin1(self): passwd = u'fo\xf3' hsh = hashlib.sha512(self.bytes_ + passwd.encode('latin1')).hexdigest() u = UserProfile(password='******' % (encodestring(self.bytes_), hsh)) assert u.check_password(self.utf) is False assert u.has_usable_password() is True
def test_persona_sha512_md5_base64(self): md5 = hashlib.md5('password').hexdigest() hsh = hashlib.sha512(self.bytes_ + md5).hexdigest() u = UserProfile(password='******' % (encodestring(self.bytes_), hsh)) assert u.check_password('password') is True assert u.has_usable_password() is True
def test_valid_old_password(self): hsh = hashlib.md5(encoding.smart_str(self.utf)).hexdigest() u = UserProfile(password=hsh) assert u.check_password(self.utf) is True # Make sure we updated the old password. algo, salt, hsh = u.password.split('$') eq_(algo, 'sha512') eq_(hsh, get_hexdigest(algo, salt, self.utf)) assert u.has_usable_password() is True
def test_valid_old_password(self): hsh = hashlib.md5(force_bytes(self.utf)).hexdigest() u = UserProfile(password=hsh) assert u.check_password(self.utf) is True # Make sure we updated the old password. algo, salt, hsh = u.password.split('$') assert algo == 'sha512' assert hsh == get_hexdigest(algo, salt, self.utf) assert u.has_usable_password() is True
def test_valid_old_password(self): hsh = hashlib.md5(force_bytes(self.utf)).hexdigest() u = UserProfile(password=hsh) assert u.check_password(self.utf) is True # Make sure we updated the old password. algo, salt, hsh = u.password.split('$') assert algo == 'sha512' assert hsh == get_hexdigest(algo, salt, self.utf) assert u.has_usable_password() is True
def test_valid_old_password(self): hsh = hashlib.md5(encoding.smart_str(self.utf)).hexdigest() u = UserProfile(password=hsh) assert u.check_password(self.utf) is True # Make sure we updated the old password. algo, salt, hsh = u.password.split('$') eq_(algo, 'sha512') eq_(hsh, get_hexdigest(algo, salt, self.utf)) assert u.has_usable_password() is True
def test_persona_sha512_base64_maybe_utf8(self): hsh = hashlib.sha512(self.bytes_ + self.utf.encode('utf8')).hexdigest() u = UserProfile(password='******' % (encodestring(self.bytes_), hsh)) assert u.check_password(self.utf) is True assert u.has_usable_password() is True
def test_valid_new_password(self): u = UserProfile() u.set_password(self.utf) assert u.check_password(self.utf) is True assert u.has_usable_password() is True
def test_invalid_new_password(self): u = UserProfile() u.set_password(self.utf) assert u.check_password('wrong') is False assert u.has_usable_password() is True
def test_invalid_old_password(self): u = UserProfile(password=self.utf) assert u.check_password(self.utf) is False assert u.has_usable_password() is True
def test_persona_sha512_base64_maybe_utf8(self): hsh = hashlib.sha512(self.bytes_ + self.utf.encode('utf8')).hexdigest() u = UserProfile(password='******' % (encodestring(self.bytes_), hsh)) assert u.check_password(self.utf) is True assert u.has_usable_password() is True
def test_valid_new_password(self): u = UserProfile() u.set_password(self.utf) assert u.check_password(self.utf) is True assert u.has_usable_password() is True
def test_invalid_new_password(self): u = UserProfile() u.set_password(self.utf) assert u.check_password('wrong') is False assert u.has_usable_password() is True
def test_invalid_old_password(self): u = UserProfile(password=self.utf) assert u.check_password(self.utf) is False assert u.has_usable_password() is True