Skip to content

Commit 686479a

Browse files
committed
Added test to make clear signed_query doesn't strip hmac
1 parent d9659d0 commit 686479a

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
* `sign_and_encode()` in favor of `laterpay.utils.signed_query()`
2424
* `sign_get_url()` in favor of `laterpay.utils.signed_url()`
2525

26+
Note that `sign_and_encode()` and `sign_get_url()` used to remove existing
27+
`'hmac'` parameters before signing query strings. This is different to
28+
`signed_query()` as that function also allows other names for the hmac query
29+
argument. Please remove the parameter yourself if need be.
30+
2631
* Removed the deprecated `cp` argument from `laterpay.ItemDefinition`
2732

2833
* Reliably ignore `hmac` and `gettoken` parameters when creating the signature

tests/test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ def test_signed_query_added_timestamp_params_not_dict(self, time_time_mock):
7070
self.assertEqual(qsd['ts'], ['123'])
7171
self.assertEqual(qsd['foo'], ['bar'])
7272

73+
def test_signed_query_keep_duplicate_signature(self):
74+
params = {'foo': 'bar', 'ts': 123, 'hmac': 'blub'}
75+
url = 'https://endpoint.com/api'
76+
secret = 'secret'
77+
78+
qs = utils.signed_query(secret, params, url)
79+
qsd = parse_qs(qs)
80+
81+
self.assertEqual(qsd['ts'], ['123'])
82+
self.assertEqual(qsd['foo'], ['bar'])
83+
self.assertEqual(qsd['hmac'], ['blub', 'af319e7ec1b7f50e054ed934f22b05bd9ff58d7783da2549efba86c1'])
84+
7385
def test_signed_url(self):
7486
params = {'foo': 'bar'}
7587
url = utils.signed_url(

0 commit comments

Comments
 (0)