def test_verify_exception(self): """ Tests that failure to verify raises the proper CCProcessorSignatureException """ params = OrderedDict() params['a'] = 'A' params['b'] = 'B' params['signedFields'] = 'A,B' params['signedDataPublicSignature'] = 'WONTVERIFY' with self.assertRaises(CCProcessorSignatureException): verify_signatures(params)
def test_sends_valid_signature(self): # Generate shoppingcart signatures post_params = sign(self.CLIENT_POST_PARAMS) # Get the POST params that the view would send back to us resp_params = PaymentFakeView.response_post_params(post_params) # Check that the client accepts these try: verify_signatures(resp_params) except CCProcessorSignatureException: self.fail("Client rejected signatures.")
def test_sign_then_verify(self): """ "loopback" test: Tests the that the verify function verifies parameters signed by the sign function """ params = OrderedDict() params['amount'] = "12.34" params['currency'] = 'usd' params['orderPage_transactionType'] = 'sale' params['orderNumber'] = "567" verify_signatures(sign(params), signed_fields_key='orderPage_signedFields', full_sig_key='orderPage_signaturePublic') # if the above verify_signature fails it will throw an exception, so basically we're just # testing for the absence of that exception. the trivial assert below does that self.assertEqual(1, 1)
def test_sign_then_verify_unicode(self): """ Similar to the test above, which loops back to the original. Testing to make sure we can handle unicode parameters """ params = { 'card_accountNumber': '1234', 'card_cardType': '001', 'billTo_firstName': u'\u2699', 'billTo_lastName': u"\u2603", 'orderNumber': '1', 'orderCurrency': 'usd', 'decision': 'ACCEPT', 'ccAuthReply_amount': '0.00' } verify_signatures(sign(params), signed_fields_key='orderPage_signedFields', full_sig_key='orderPage_signaturePublic') # if the above verify_signature fails it will throw an exception, so basically we're just # testing for the absence of that exception. the trivial assert below does that self.assertEqual(1, 1)