Skip to content

Commit

Permalink
decodeSignedData not raise exception if redsys sends unexpected param
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjiRS94 authored and vokimon committed Dec 9, 2021
1 parent 3e2d646 commit 88c028d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
4 changes: 0 additions & 4 deletions sermepa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ def error(message):
camell = _notification_fields_upper[key]
data[camell]=data[key]
del data[key]
continue

if key not in _notification_fields:
error("Bad parameter '{}'".format(key))

return data

Expand Down
20 changes: 10 additions & 10 deletions sermepa/sermepa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,19 @@ def test_decodeSignedData_badSignature(self):
msg = cm.exception.args[0]
self.assertEqual(msg, 'Bad signature')

def test_decodeSignedData_badParam(self):
def test_decodeSignedData_unexpectedParam(self):
json_data = '{"Ds_Order":"666", "Bad":"value"}'
base64_data = base64.urlsafe_b64encode(b(json_data))
signature = signPayload(self.secret, base64_data, urlsafe=True)
with self.assertRaises(SignatureError) as cm:
decodeSignedData(
self.merchantkey,
Ds_MerchantParameters = base64_data,
Ds_Signature = signature,
Ds_SignatureVersion = self.signatureversion,
)
msg = cm.exception.args[0]
self.assertEqual(msg, "Bad parameter 'Bad'")

data = decodeSignedData(
self.merchantkey,
Ds_MerchantParameters=base64_data,
Ds_Signature=signature,
Ds_SignatureVersion=self.signatureversion,
)

self.assertEqual(data, dict(Ds_Order='666', Bad='value'))

def test_decodeSignedData_upperCaseOrder(self):
json_data = '{"DS_ORDER":"666"}'
Expand Down

0 comments on commit 88c028d

Please sign in to comment.