예제 #1
0
    def test_set_payment_status(self):

        # Generate shoppingcart signatures
        post_params = sign(self.client_post_params)
        # Configure the view to declined payments
        resp = self.client.put('/shoppingcart/payment_fake',
                               data="decline",
                               content_type='text/plain')
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "DECLINE"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'DECLINE')

        # Configure the view to fail payments
        resp = self.client.put('/shoppingcart/payment_fake',
                               data="failure",
                               content_type='text/plain')
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "REJECT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'REJECT')

        # Configure the view to accept payments
        resp = self.client.put('/shoppingcart/payment_fake',
                               data="success",
                               content_type='text/plain')
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "ACCEPT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'ACCEPT')
예제 #2
0
    def test_set_payment_status(self):

        # Generate shoppingcart signatures
        post_params = sign(self.CLIENT_POST_PARAMS)

        # Configure the view to fail payments
        resp = self.client.put(
            '/shoppingcart/payment_fake',
            data="failure", content_type='text/plain'
        )
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "REJECT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'REJECT')

        # Configure the view to accept payments
        resp = self.client.put(
            '/shoppingcart/payment_fake',
            data="success", content_type='text/plain'
        )
        self.assertEqual(resp.status_code, 200)

        # Check that the decision is "ACCEPT"
        resp_params = PaymentFakeView.response_post_params(post_params)
        self.assertEqual(resp_params.get('decision'), 'ACCEPT')
예제 #3
0
    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.")
예제 #4
0
    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.")
예제 #5
0
    def test_rejects_invalid_signature(self):

        # Generate shoppingcart signatures
        post_params = sign(self.client_post_params)

        # Tamper with the signature
        post_params['signature'] = "invalid"

        # Simulate a POST request from the payment workflow
        # page to the fake payment page.
        resp = self.client.post('/shoppingcart/payment_fake',
                                dict(post_params))

        # Expect that we got an error
        self.assertContains(resp, "Error")
예제 #6
0
    def test_accepts_client_signatures(self):

        # Generate shoppingcart signatures
        post_params = sign(self.client_post_params)

        # Simulate a POST request from the payment workflow
        # page to the fake payment page.
        resp = self.client.post('/shoppingcart/payment_fake',
                                dict(post_params))

        # Expect that the response was successful
        self.assertEqual(resp.status_code, 200)

        # Expect that we were served the payment page
        # (not the error page)
        self.assertContains(resp, "Payment Form")
예제 #7
0
    def test_rejects_invalid_signature(self):

        # Generate shoppingcart signatures
        post_params = sign(self.CLIENT_POST_PARAMS)

        # Tamper with the signature
        post_params['signature'] = "invalid"

        # Simulate a POST request from the payment workflow
        # page to the fake payment page.
        resp = self.client.post(
            '/shoppingcart/payment_fake', dict(post_params)
        )

        # Expect that we got an error
        self.assertIn("Error", resp.content)
예제 #8
0
    def test_accepts_client_signatures(self):

        # Generate shoppingcart signatures
        post_params = sign(self.CLIENT_POST_PARAMS)

        # Simulate a POST request from the payment workflow
        # page to the fake payment page.
        resp = self.client.post(
            '/shoppingcart/payment_fake', dict(post_params)
        )

        # Expect that the response was successful
        self.assertEqual(resp.status_code, 200)

        # Expect that we were served the payment page
        # (not the error page)
        self.assertIn("Payment Form", resp.content)