Beispiel #1
0
    def test_validate(self, digest, decode, base64, time):
        time.return_value = 10
        decode.return_value = Policy('', 20)
        key = Mock()
        encoded = '12345=='
        signature = '0x44'

        # test
        policy = Policy.validate(key, encoded, signature)

        # validation
        digest.assert_called_once_with(encoded)
        base64.decode.assert_called_once_with(signature)
        key.verify.assert_called_once_with(digest.return_value, base64.decode.return_value)
        decode.assert_called_once_with(encoded)
        self.assertEqual(policy, decode.return_value)