Skip to content

Commit f08e7d8

Browse files
committed
Add some ramblings
This PR improved upon the tests, but there's always work left to do. This commits adds a few of my ramblings about how we could improve further.
1 parent 816a155 commit f08e7d8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

adyen/scaffold.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class Scaffold:
1010
# These are the constants that all scaffolds are expected to return
1111
# to a multi-psp application. They might look like those actually returned
1212
# by the psp itself, but that would be a pure coincidence.
13+
# At some point we could discuss merging cancelled & refused & error and just
14+
# ensuring good error messages are returned. I doubt the distinction is
15+
# important to most checkout procedures.
1316
PAYMENT_STATUS_ACCEPTED = 'ACCEPTED'
1417
PAYMENT_STATUS_CANCELLED = 'CANCELLED'
1518
PAYMENT_STATUS_REFUSED = 'REFUSED'

tests/test_redirects.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
class TestAdyenPaymentRedirects(TestCase):
2525
"""
26-
Test case that tests Adyen payment redirects (user redirected from Adyen to us)
26+
Test case that tests Adyen payment redirects (user redirected from Adyen to us).
27+
28+
Note that notifications and redirects are pretty similar and share a lot of
29+
common code. So those tests will actually test a lot of code for notifications
30+
as well. In an ideal world, we'd split things up to check the shared code individually.
2731
"""
2832

2933
def test_handle_authorised_payment(self):
@@ -129,6 +133,15 @@ def test_handle_refused_payment(self):
129133
assert AdyenTransaction.objects.filter(status='REFUSED').count() == 1
130134

131135
def test_signing_is_enforced(self):
136+
"""
137+
Test that the supplied signature (in field merchantSig) is checked and
138+
notifications are ignored when the signature doesn't match.
139+
140+
In an ideal world, our other tests would ignore the signature checking
141+
because it's annoying to have to alter the sig when altering the fake
142+
data. Maik gets valid signatures by adding a print(expected_hash) to
143+
PaymentRedirection.validate.
144+
"""
132145
fake_signature = copy(AUTHORISED_PAYMENT_PARAMS_GET)
133146
fake_signature['merchantSig'] = '14M4N3V1LH4X0RZ'
134147
signature_none = copy(AUTHORISED_PAYMENT_PARAMS_GET)

0 commit comments

Comments
 (0)