def testMismatchedUUID(self): """Test error response if invalid secret UUID""" current_site = Site.objects.get_current() incorrect_UUID = 'thisisnotthecorrectuuid' kwargs = {'object_id': self.payment.id, 'object_secret_uuid': incorrect_UUID} internal_url = reverse('paypal-adaptive-ipn', kwargs=kwargs) ipn_url = "%s://%s%s" % (get_http_protocol(), current_site, internal_url) money = "%s %s" % (self.payment.money.currency, self.payment.money.amount) data = { 'status': 'COMPLETED', 'transaction_type': 'Adaptive Payment PAY', 'transaction[0].id': '1', 'transaction[0].amount': money, 'transaction[0].status': 'COMPLETED', } response = self.mock_ipn_call(data, ipn_url) payment = self.get_payment() self.assertEqual(payment.status, 'error') self.assertEqual(payment.status_detail, ('IPN secret "%s" did not match db' % incorrect_UUID)) self.assertEqual(response.status_code, 400)
def test404MissingObject(self): """Test 404 if missing object""" current_site = Site.objects.get_current() incorrect_UUID = 'thisisnotthecorrectuuid' incorrect_object_id = 9000 kwargs = { 'object_id': incorrect_object_id, 'object_secret_uuid': incorrect_UUID } internal_url = reverse('paypal-adaptive-ipn', kwargs=kwargs) ipn_url = "%s://%s%s" % (get_http_protocol(), current_site, internal_url) money = '%s %s' % (self.payment.money.currency, self.payment.money.amount) data = { 'status': 'COMPLETED', 'transaction_type': 'Adaptive Payment PAY', 'transaction[0].id': '1', 'transaction[0].amount': money, 'transaction[0].status': 'COMPLETED', } response = self.mock_ipn_call(data, ipn_url) self.assertEqual(response.status_code, 404)
def testMismatchedUUID(self): """Test error response if invalid secret UUID""" current_site = Site.objects.get_current() incorrect_UUID = 'thisisnotthecorrectuuid' kwargs = { 'object_id': self.payment.id, 'object_secret_uuid': incorrect_UUID } internal_url = reverse('paypal-adaptive-ipn', kwargs=kwargs) ipn_url = "%s://%s%s" % (get_http_protocol(), current_site, internal_url) money = "%s %s" % (self.payment.money.currency, self.payment.money.amount) data = { 'status': 'COMPLETED', 'transaction_type': 'Adaptive Payment PAY', 'transaction[0].id': '1', 'transaction[0].amount': money, 'transaction[0].status': 'COMPLETED', } response = self.mock_ipn_call(data, ipn_url) payment = self.get_payment() self.assertEqual(payment.status, 'error') self.assertEqual(payment.status_detail, ('IPN secret "%s" did not match db' % incorrect_UUID)) self.assertEqual(response.status_code, 400)
def test404MissingObject(self): """Test 404 if missing object""" current_site = Site.objects.get_current() incorrect_UUID = 'thisisnotthecorrectuuid' incorrect_object_id = 9000 kwargs = {'object_id': incorrect_object_id, 'object_secret_uuid': incorrect_UUID} internal_url = reverse('paypal-adaptive-ipn', kwargs=kwargs) ipn_url = "%s://%s%s" % (get_http_protocol(), current_site, internal_url) money = '%s %s' % (self.payment.money.currency, self.payment.money.amount) data = { 'status': 'COMPLETED', 'transaction_type': 'Adaptive Payment PAY', 'transaction[0].id': '1', 'transaction[0].amount': money, 'transaction[0].status': 'COMPLETED', } response = self.mock_ipn_call(data, ipn_url) self.assertEqual(response.status_code, 404)
def _assert_valid_reversed_url(self, url, kwargs, template_name): """"Helper function for return and cancel urls""" current_site = Site.objects.get_current() return_url = reverse(template_name, kwargs=kwargs) assert url == "%s://%s%s" % (get_http_protocol(), current_site, return_url)