Skip to content

Commit 0285102

Browse files
Correct the copy for dict_object (#284)
* Correct the copy for dict_object * remove extra check
1 parent d4574ff commit 0285102

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

Adyen/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import hmac
55
import hashlib
66
import binascii
7+
import copy
8+
79

810

911
def generate_notification_sig(dict_object, hmac_key):
@@ -35,7 +37,7 @@ def generate_notification_sig(dict_object, hmac_key):
3537

3638

3739
def is_valid_hmac_notification(dict_object, hmac_key):
38-
dict_object = dict_object.copy()
40+
dict_object = copy.deepcopy(dict_object)
3941

4042
if 'notificationItems' in dict_object:
4143
dict_object = dict_object['notificationItems'][0]['NotificationRequestItem']

test/UtilTest.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,29 @@ def test_custom_version(self):
107107
headers={'adyen-library-name': settings.LIB_NAME, 'adyen-library-version': settings.LIB_VERSION},
108108
json=request,
109109
xapikey="YourXapikey"
110-
)
110+
)
111+
112+
def test_is_valid_hmac_notification_removes_additional_data(self):
113+
notification = {
114+
"live":"false",
115+
"notificationItems":[
116+
{
117+
"NotificationRequestItem":{
118+
"additionalData":{
119+
"hmacSignature":"11aa",
120+
"fraudResultType":"GREEN",
121+
"fraudManualReview": "false",
122+
"totalFraudScore":"75"
123+
},
124+
"amount":{
125+
"currency":"USD",
126+
"value":10000
127+
},
128+
"success":"true"
129+
130+
}
131+
}
132+
]}
133+
is_valid_hmac_notification(notification, "11aa")
134+
self.assertIsNotNone(notification['notificationItems'][0]['NotificationRequestItem']['additionalData'])
135+

0 commit comments

Comments
 (0)