def test_decodeSignedData_badParam(self): json_data = '{"Ds_Order":"666", "Bad":"value"}' base64_data = base64.urlsafe_b64encode(json_data) signature = signPayload(self.secret, base64_data, urlsafe=True) with self.assertRaises(SignatureError) as cm: decodeSignedData( self.merchantkey, Ds_MerchantParameters = base64_data, Ds_Signature = signature, Ds_SignatureVersion = self.signatureversion, ) msg = cm.exception.args[0] self.assertEqual(msg, "Bad parameter 'Bad'")
def test_decodeSignedData_unicode(self): json_data = '{"DS_ORDER":"666"}' base64_data = base64.urlsafe_b64encode(json_data) signature = signPayload(self.secret, base64_data, urlsafe=True) data = decodeSignedData( self.merchantkey, Ds_MerchantParameters = base64_data.decode('ascii'), Ds_Signature = signature.decode('ascii'), Ds_SignatureVersion = self.signatureversion.decode('ascii'), ) self.assertEqual(data, dict( Ds_Order = '666', ))
def test_signPayload(self): signature = signPayload(self.secret, self.encodedPayload) self.assertMultiLineEqual(signature, self.signature)
def test_computeKey(self): signature = signPayload(self.secret, self.encodeddata, urlsafe=True) self.assertMultiLineEqual(self.signature, signature)