diff --git a/passerelle/apps/esup_signature/models.py b/passerelle/apps/esup_signature/models.py index d99581a9..af210ce7 100644 --- a/passerelle/apps/esup_signature/models.py +++ b/passerelle/apps/esup_signature/models.py @@ -140,12 +140,12 @@ class EsupSignature(BaseResource, HTTPResource): class Meta: verbose_name = _('Esup Signature') - def _call(self, path, method='get', data=None, files=None, expect_json=True): + def _call(self, path, method='get', params=None, files=None, expect_json=True): url = urllib.parse.urljoin(self.base_url, path) kwargs = {} if method == 'post': - kwargs['data'] = data + kwargs['params'] = params kwargs['files'] = files try: @@ -206,7 +206,7 @@ class EsupSignature(BaseResource, HTTPResource): ) } - data = { + params = { 'signType': 'pdfImageStamp', 'recipientsEmails': clean_list(post_data['recipients_emails']), 'eppn': post_data['eppn'], @@ -214,7 +214,7 @@ class EsupSignature(BaseResource, HTTPResource): 'pending': True, } - return {'data': self._call('ws/signrequests/new', method='post', data=data, files=files)} + return {'data': self._call('ws/signrequests/new', method='post', params=params, files=files)} @endpoint( name='new-with-workflow', @@ -263,7 +263,7 @@ class EsupSignature(BaseResource, HTTPResource): ) } - data = { + params = { 'createByEppn': post_data['eppn'], 'title': post_data.get('title', ''), 'recipientsEmails': clean_list(post_data.get('recipients_emails', [])), @@ -275,7 +275,7 @@ class EsupSignature(BaseResource, HTTPResource): return { 'data': self._call( - '/ws/workflows/%s/new' % post_data['workflow_id'], method='post', data=data, files=files + '/ws/workflows/%s/new' % post_data['workflow_id'], method='post', params=params, files=files ) } diff --git a/tests/test_esup_signature.py b/tests/test_esup_signature.py index 36c85a38..b6411c02 100644 --- a/tests/test_esup_signature.py +++ b/tests/test_esup_signature.py @@ -35,7 +35,19 @@ def test_new(app, connector): 'title': 'a title', } with responses.RequestsMock() as rsps: - rsps.post('https://esup-signature.invalid/ws/signrequests/new', status=200, json=9) + query_params = { + 'recipientsEmails': ['foo@invalid', 'bar@invalid'], + 'eppn': 'baz@invalid', + 'title': 'a title', + 'signType': 'pdfImageStamp', + 'pending': True, + } + rsps.post( + 'https://esup-signature.invalid/ws/signrequests/new', + match=[responses.matchers.query_param_matcher(query_params)], + status=200, + json=9, + ) resp = app.post_json('/esup-signature/esup-signature/new', params=params) assert len(rsps.calls) == 1 assert rsps.calls[0].request.headers['Content-Type'].startswith('multipart/form-data') @@ -68,7 +80,22 @@ def test_new_with_workflow(app, connector): 'target_urls/1': 'smb://foo.bar/location-2/', } with responses.RequestsMock() as rsps: - rsps.post('https://esup-signature.invalid/ws/workflows/99/new', status=200, json=9) + query_params = { + 'createByEppn': 'aa@foo.com', + 'title': 'a title', + 'recipientsEmails': ['0*xx@foo.com', '0*yy@foo.com', '1*zz@foo.com'], + 'allSignToCompletes': ['12', '13'], + 'targetEmails': ['xx@foo.com', 'yy@foo.com', 'zz@foo.com'], + 'signRequestParamsJsonString': 'List [ OrderedMap { "xPos": 100, "yPos": 100, "signPageNumber": 1 }, ' + 'OrderedMap { "xPos": 200, "yPos": 200, "signPageNumber": 1 } ]', + 'targetUrls': ['smb://foo.bar/location-1/', 'smb://foo.bar/location-2/'], + } + rsps.post( + 'https://esup-signature.invalid/ws/workflows/99/new', + match=[responses.matchers.query_param_matcher(query_params)], + status=200, + json=9, + ) resp = app.post_json('/esup-signature/esup-signature/new-with-workflow', params=params) assert len(rsps.calls) == 1 assert rsps.calls[0].request.headers['Content-Type'].startswith('multipart/form-data')