summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2018-08-22 21:14:53 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2018-08-22 21:14:53 (GMT)
commite8f12c5d1fd7b9cf5bd2526898b2004a3bbee8b0 (patch)
treeb7a35299b288c0c84f0146fa51a0798d84458c3b /tests
parentcdd3295e398be15d4327c4bd5309b2dfd194fd23 (diff)
downloadeopayment-e8f12c5d1fd7b9cf5bd2526898b2004a3bbee8b0.zip
eopayment-e8f12c5d1fd7b9cf5bd2526898b2004a3bbee8b0.tar.gz
eopayment-e8f12c5d1fd7b9cf5bd2526898b2004a3bbee8b0.tar.bz2
add a message in ResponseErrors (#25773)v1.26
Diffstat (limited to 'tests')
-rw-r--r--tests/test_dummy.py5
-rw-r--r--tests/test_ogone.py2
-rw-r--r--tests/test_paybox.py3
-rw-r--r--tests/test_sips2.py5
-rw-r--r--tests/test_spplus.py4
-rw-r--r--tests/test_systempayv2.py6
-rw-r--r--tests/test_tipi.py4
7 files changed, 28 insertions, 1 deletions
diff --git a/tests/test_dummy.py b/tests/test_dummy.py
index caac610..1725673 100644
--- a/tests/test_dummy.py
+++ b/tests/test_dummy.py
@@ -1,4 +1,5 @@
import eopayment
+import pytest
def test_dummy():
options = {
@@ -17,3 +18,7 @@ def test_dummy():
assert r.signed
assert r.transaction_id == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T'
assert r.return_content == 'signature ok'
+
+ data = {'foo': 'bar'}
+ with pytest.raises(eopayment.ResponseError, match='missing transaction_id'):
+ p.response('foo=bar')
diff --git a/tests/test_ogone.py b/tests/test_ogone.py
index b667445..c44596d 100644
--- a/tests/test_ogone.py
+++ b/tests/test_ogone.py
@@ -76,7 +76,7 @@ class OgoneTests(TestCase):
ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS)
order_id = 'myorder'
data = {'payid': '32100123', 'status': 9, 'ncerror': 0}
- with self.assertRaises(ResponseError):
+ with self.assertRaisesRegexp(ResponseError, 'missing ORDERID, PAYID, STATUS or NCERROR'):
response = ogone_backend.response(urllib.urlencode(data))
def test_bank_transfer_response(self):
diff --git a/tests/test_paybox.py b/tests/test_paybox.py
index bedcb69..abea656 100644
--- a/tests/test_paybox.py
+++ b/tests/test_paybox.py
@@ -92,6 +92,9 @@ class PayboxTests(TestCase):
response = backend.response(urllib.urlencode(data))
self.assertEqual(response.order_id, order_id)
+ with self.assertRaisesRegexp(eopayment.ResponseError, 'missing erreur or reference'):
+ backend.response('foo=bar')
+
def test_rsa_signature_validation(self):
pkey = '''-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUgYufHuheMztK1LhQSG6xsOzb
diff --git a/tests/test_sips2.py b/tests/test_sips2.py
index a2250b4..65e63f1 100644
--- a/tests/test_sips2.py
+++ b/tests/test_sips2.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
import eopayment
+import pytest
+
def test_build_request():
backend = eopayment.Payment('sips2', {})
@@ -31,3 +33,6 @@ def test_parse_response():
qs = '''Data=captureDay%3D0%7CcaptureMode%3DAUTHOR_CAPTURE%7CcurrencyCode%3D978%7CmerchantId%3D002001000000001%7CorderChannel%3DINTERNET%7CresponseCode%3D00%7CtransactionDateTime%3D2016-02-01T17%3A44%3A20%2B01%3A00%7CtransactionReference%3D668930%7CkeyVersion%3D1%7CacquirerResponseCode%3D00%7Camount%3D1200%7CauthorisationId%3D12345%7CcardCSCResultCode%3D4E%7CpanExpiryDate%3D201605%7CpaymentMeanBrand%3DMASTERCARD%7CpaymentMeanType%3DCARD%7CcustomerIpAddress%3D82.244.203.243%7CmaskedPan%3D5100%23%23%23%23%23%23%23%23%23%23%23%2300%7CorderId%3Dd4903de7027f4d56ac01634fd7ab9526%7CholderAuthentRelegation%3DN%7CholderAuthentStatus%3D3D_ERROR%7CtransactionOrigin%3DINTERNET%7CpaymentPattern%3DONE_SHOT&Seal=6ca3247765a19b45d25ad54ef4076483e7d55583166bd5ac9c64357aac097602&InterfaceVersion=HP_2.0&Encode='''
backend = eopayment.Payment('sips2', {})
assert backend.response(qs)
+
+ with pytest.raises(eopayment.ResponseError, match='missing Data, Seal or InterfaceVersion'):
+ backend.response('foo=bar')
diff --git a/tests/test_spplus.py b/tests/test_spplus.py
index a1a2058..ba047e9 100644
--- a/tests/test_spplus.py
+++ b/tests/test_spplus.py
@@ -1,5 +1,6 @@
from unittest import TestCase
import eopayment.spplus as spplus
+from eopayment import ResponseError
class SPPlustTest(TestCase):
ntkey = b'58 6d fc 9c 34 91 9b 86 3f ' \
@@ -14,3 +15,6 @@ class SPPlustTest(TestCase):
for query, result in self.tests:
self.assertEqual(spplus.sign_ntkey_query(self.ntkey, query).lower(), result)
+
+ with self.assertRaisesRegexp(ResponseError, 'missing reference, etat or refsfp'):
+ payment.response('foo=bar')
diff --git a/tests/test_systempayv2.py b/tests/test_systempayv2.py
index c558bbf..bf00b6d 100644
--- a/tests/test_systempayv2.py
+++ b/tests/test_systempayv2.py
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
+import pytest
from six.moves.urllib import parse as urlparse
from eopayment.systempayv2 import Payment, VADS_CUST_FIRST_NAME, \
VADS_CUST_LAST_NAME, PAID
+from eopayment import ResponseError
PARAMS = {
'secret_test': u'1122334455667788',
@@ -43,3 +45,7 @@ def test_systempayv2():
'&signature=62a4fb6738ebadebf9cc720164bc70e47282d36e'
response = p.response(response_qs)
assert response.result == PAID
+
+ # bad response
+ with pytest.raises(ResponseError, match='missing signature, vads_ctx_mode or vads_auth_result'):
+ p.response('foo=bar')
diff --git a/tests/test_tipi.py b/tests/test_tipi.py
index 2f8a665..f33bae5 100644
--- a/tests/test_tipi.py
+++ b/tests/test_tipi.py
@@ -1,6 +1,7 @@
from decimal import Decimal
from six.moves.urllib.parse import urlparse, parse_qs
import eopayment
+import pytest
def test_tipi():
p = eopayment.Payment('tipi', {'numcli': '12345'})
@@ -23,3 +24,6 @@ def test_tipi():
response = p.response('objet=tout+a+fait&montant=12312&saisie=T&mel=info%40entrouvert.com&numcli=12345&exer=9999&refdet=999900000000999999&resultrans=P')
assert response.signed # ...
assert response.result == eopayment.PAID
+
+ with pytest.raises(eopayment.ResponseError, match='missing refdet or resultrans'):
+ p.response('foo=bar')