From 234ed7635b6fb059ad800b947e74216f60b9c140 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 31 May 2016 11:25:41 -0400 Subject: [PATCH] Reset client post parameters after each payment_fake test, because the sign method modifies the supplied dictionary --- .../shoppingcart/tests/test_payment_fake.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lms/djangoapps/shoppingcart/tests/test_payment_fake.py b/lms/djangoapps/shoppingcart/tests/test_payment_fake.py index f087aa4ad4..e28997a965 100644 --- a/lms/djangoapps/shoppingcart/tests/test_payment_fake.py +++ b/lms/djangoapps/shoppingcart/tests/test_payment_fake.py @@ -15,32 +15,32 @@ class PaymentFakeViewTest(TestCase): correctly with the shopping cart. """ - CLIENT_POST_PARAMS = OrderedDict([ - ('amount', '25.00'), - ('currency', 'usd'), - ('transaction_type', 'sale'), - ('orderNumber', '33'), - ('access_key', '123456789'), - ('merchantID', 'edx'), - ('djch', '012345678912'), - ('orderPage_version', 2), - ('orderPage_serialNumber', '1234567890'), - ('profile_id', "00000001"), - ('reference_number', 10), - ('locale', 'en'), - ('signed_date_time', '2014-08-18T13:59:31Z'), - ]) - def setUp(self): super(PaymentFakeViewTest, self).setUp() # Reset the view state PaymentFakeView.PAYMENT_STATUS_RESPONSE = "success" + self.client_post_params = OrderedDict([ + ('amount', '25.00'), + ('currency', 'usd'), + ('transaction_type', 'sale'), + ('orderNumber', '33'), + ('access_key', '123456789'), + ('merchantID', 'edx'), + ('djch', '012345678912'), + ('orderPage_version', 2), + ('orderPage_serialNumber', '1234567890'), + ('profile_id', "00000001"), + ('reference_number', 10), + ('locale', 'en'), + ('signed_date_time', '2014-08-18T13:59:31Z'), + ]) + def test_accepts_client_signatures(self): # Generate shoppingcart signatures - post_params = sign(self.CLIENT_POST_PARAMS) + post_params = sign(self.client_post_params) # Simulate a POST request from the payment workflow # page to the fake payment page. @@ -58,7 +58,7 @@ class PaymentFakeViewTest(TestCase): def test_rejects_invalid_signature(self): # Generate shoppingcart signatures - post_params = sign(self.CLIENT_POST_PARAMS) + post_params = sign(self.client_post_params) # Tamper with the signature post_params['signature'] = "invalid" @@ -75,7 +75,7 @@ class PaymentFakeViewTest(TestCase): def test_sends_valid_signature(self): # Generate shoppingcart signatures - post_params = sign(self.CLIENT_POST_PARAMS) + 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) @@ -90,7 +90,7 @@ class PaymentFakeViewTest(TestCase): def test_set_payment_status(self): # Generate shoppingcart signatures - post_params = sign(self.CLIENT_POST_PARAMS) + post_params = sign(self.client_post_params) # Configure the view to declined payments resp = self.client.put(