def test_response_decoder(self): data = dict(field='value') encoded = encode_data(data) signature = generate_signature(self.private_key, encoded) decoded = decode_response_data(self.private_key, encoded, signature) self.assertEqual(data, decoded) self.assertRaises(SignatureMismatch, decode_response_data, self.private_key, encoded, 'privateKey2')
def test_signature_generation(self): expected = 'cJxZYijbaA+bXqIJIPSV1G0v8DI=' data = dict(field='value') signature = generate_signature(self.private_key, data) self.assertEqual(expected, signature) data = encode_data(data) signature = generate_signature(self.private_key, data) self.assertEqual(expected, signature)
def test_data_encoding(self): expected = 'eyJmaWVsZCI6ICJ2YWx1ZSJ9' data = dict(field='value') encoded = encode_data(data) self.assertEqual(expected, encoded)