コード例 #1
0
 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('')
コード例 #2
0
 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('')
コード例 #3
0
 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
コード例 #4
0
 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
コード例 #5
0
 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
コード例 #6
0
 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
コード例 #7
0
ファイル: test_models.py プロジェクト: gffbss/addons-server
 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
コード例 #8
0
 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
コード例 #9
0
 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
コード例 #10
0
 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
コード例 #11
0
 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
コード例 #12
0
 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
コード例 #13
0
 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
コード例 #14
0
 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
コード例 #15
0
 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
コード例 #16
0
 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
コード例 #17
0
 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
コード例 #18
0
 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