Beispiel #1
0
 def test_to_python_invalid_digest(self):
     field = ChallengeField('md5')
     with pytest.raises(ValueError):
         field.to_python(None, {
             'salt': base64.b64encode(b'salt').decode(),
             'digest': '==Za'
         })
Beispiel #2
0
 def test_to_python_invalid_salt(self):
     field = ChallengeField('md5')
     with pytest.raises(ValueError):
         field.to_python(MockConfig(), {
             'salt': '==Zaa',
             'digest': base64.b64encode(b'digest').decode()
         })
Beispiel #3
0
 def test_to_python_dict(self):
     field = ChallengeField('md5')
     salt = base64.b64encode(b'salt').decode()
     digest = base64.b64encode(b'digest').decode()
     val = field.to_python(MockConfig(), {'salt': salt, 'digest': digest})
     assert val.salt == b'salt'
     assert val.digest == b'digest'
     assert val.algorithm is hashlib.md5
Beispiel #4
0
 def test_to_python_none(self):
     field = ChallengeField('md5', key='test')
     assert field.to_python(None, None) is None
Beispiel #5
0
 def test_to_python_error(self):
     field = ChallengeField('md5')
     with pytest.raises(ValueError):
         field.to_python(None, 100)
Beispiel #6
0
 def test_to_python_str(self):
     field = ChallengeField('md5')
     field._hash = MagicMock()
     field.to_python(None, 'message')
     field._hash.assert_called_with('message')