esup_signature: add parameters to the 'new' endpoint (#77670)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
6b74e9a632
commit
0c06086585
|
@ -35,7 +35,7 @@ SIGN_REQUEST_SCHEMA = {
|
||||||
'title': '',
|
'title': '',
|
||||||
'description': '',
|
'description': '',
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'required': ['file', 'recipients_emails', 'eppn'],
|
'required': ['file', 'recipients_emails', 'create_by_eppn'],
|
||||||
'unflatten': True,
|
'unflatten': True,
|
||||||
'properties': collections.OrderedDict(
|
'properties': collections.OrderedDict(
|
||||||
{
|
{
|
||||||
|
@ -62,8 +62,48 @@ SIGN_REQUEST_SCHEMA = {
|
||||||
'description': 'Recipients emails',
|
'description': 'Recipients emails',
|
||||||
'items': {'type': 'string'},
|
'items': {'type': 'string'},
|
||||||
},
|
},
|
||||||
'eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
'recipients_cc_emails': {
|
||||||
|
'type': 'array',
|
||||||
|
'description': 'Recipients CC emails',
|
||||||
|
'items': {'type': 'string'},
|
||||||
|
},
|
||||||
|
'all_sign_to_complete': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Every recipient has to sign',
|
||||||
|
'enum': ['true', 'false'],
|
||||||
|
'default': 'false',
|
||||||
|
},
|
||||||
|
'user_sign_first': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'the author must sign first',
|
||||||
|
'enum': ['true', 'false'],
|
||||||
|
'default': 'false',
|
||||||
|
},
|
||||||
|
'pending': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Pending',
|
||||||
|
'enum': ['true', 'false'],
|
||||||
|
'default': 'true',
|
||||||
|
},
|
||||||
|
'force_all_sign': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Force signing on every document',
|
||||||
|
'enum': ['true', 'false'],
|
||||||
|
'default': 'false',
|
||||||
|
},
|
||||||
|
'comment': {'type': 'string', 'description': 'Comment'},
|
||||||
|
'sign_type': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Signature type',
|
||||||
|
'enum': ['visa', 'pdfImageStamp', 'certSign', 'nexuSign'],
|
||||||
|
'default': 'pdfImageStamp',
|
||||||
|
},
|
||||||
|
'create_by_eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||||
'title': {'type': 'string', 'description': 'Title'},
|
'title': {'type': 'string', 'description': 'Title'},
|
||||||
|
'target_url': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'End location',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -132,6 +172,10 @@ def clean_list(some_list):
|
||||||
return [elem for elem in some_list if elem]
|
return [elem for elem in some_list if elem]
|
||||||
|
|
||||||
|
|
||||||
|
def to_bool(some_str):
|
||||||
|
return some_str == 'true'
|
||||||
|
|
||||||
|
|
||||||
class EsupSignature(BaseResource, HTTPResource):
|
class EsupSignature(BaseResource, HTTPResource):
|
||||||
base_url = models.URLField(_('API URL'))
|
base_url = models.URLField(_('API URL'))
|
||||||
|
|
||||||
|
@ -188,8 +232,18 @@ class EsupSignature(BaseResource, HTTPResource):
|
||||||
'recipients_emails/0': 'xx@foo.com',
|
'recipients_emails/0': 'xx@foo.com',
|
||||||
'recipients_emails/1': 'yy@foo.com',
|
'recipients_emails/1': 'yy@foo.com',
|
||||||
'recipients_emails/2': 'zz@foo.com',
|
'recipients_emails/2': 'zz@foo.com',
|
||||||
'eppn': 'aa@foo.com',
|
'recipients_cc_emails/0': 'xx@foo.com',
|
||||||
|
'recipients_cc_emails/1': 'yy@foo.com',
|
||||||
|
'recipients_cc_emails/2': 'zz@foo.com',
|
||||||
|
'all_sign_to_complete': 'true',
|
||||||
|
'user_sign_first': 'false',
|
||||||
|
'pending': 'true',
|
||||||
|
'force_all_sign': 'false',
|
||||||
|
'comment': 'a comment',
|
||||||
|
'sign_type': 'pdfImageStamp',
|
||||||
|
'create_by_eppn': 'aa@foo.com',
|
||||||
'title': 'a title',
|
'title': 'a title',
|
||||||
|
'target_url': 'smb://foo.bar/location-1/',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -207,13 +261,27 @@ class EsupSignature(BaseResource, HTTPResource):
|
||||||
}
|
}
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'signType': 'pdfImageStamp',
|
|
||||||
'recipientsEmails': clean_list(post_data['recipients_emails']),
|
'recipientsEmails': clean_list(post_data['recipients_emails']),
|
||||||
'eppn': post_data['eppn'],
|
'recipientsCCEmails': clean_list(post_data.get('recipients_cc_emails', [])),
|
||||||
|
'comment': post_data.get('comment', ''),
|
||||||
|
'signType': post_data.get('sign_type', 'pdfImageStamp'),
|
||||||
|
'createByEppn': post_data['create_by_eppn'],
|
||||||
'title': post_data.get('title', ''),
|
'title': post_data.get('title', ''),
|
||||||
'pending': True,
|
'targetUrl': post_data.get('target_url', ''),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool_params = {
|
||||||
|
'all_sign_to_complete': ('allSignToComplete', False),
|
||||||
|
'user_sign_first': ('userSignFirst', False),
|
||||||
|
'pending': ('pending', True),
|
||||||
|
'force_all_sign': ('forceAllSign', False),
|
||||||
|
}
|
||||||
|
for key, value in bool_params.items():
|
||||||
|
ext_param, default = value
|
||||||
|
params[ext_param] = default
|
||||||
|
if key in post_data:
|
||||||
|
params[ext_param] = to_bool(post_data[key])
|
||||||
|
|
||||||
return {'data': self._call('ws/signrequests/new', method='post', params=params, files=files)}
|
return {'data': self._call('ws/signrequests/new', method='post', params=params, files=files)}
|
||||||
|
|
||||||
@endpoint(
|
@endpoint(
|
||||||
|
|
|
@ -31,16 +31,19 @@ def test_new(app, connector):
|
||||||
},
|
},
|
||||||
'recipients_emails/0': 'foo@invalid',
|
'recipients_emails/0': 'foo@invalid',
|
||||||
'recipients_emails/1': 'bar@invalid',
|
'recipients_emails/1': 'bar@invalid',
|
||||||
'eppn': 'baz@invalid',
|
'create_by_eppn': 'baz@invalid',
|
||||||
'title': 'a title',
|
'title': 'a title',
|
||||||
}
|
}
|
||||||
with responses.RequestsMock() as rsps:
|
with responses.RequestsMock() as rsps:
|
||||||
query_params = {
|
query_params = {
|
||||||
'recipientsEmails': ['foo@invalid', 'bar@invalid'],
|
'recipientsEmails': ['foo@invalid', 'bar@invalid'],
|
||||||
'eppn': 'baz@invalid',
|
'createByEppn': 'baz@invalid',
|
||||||
'title': 'a title',
|
'title': 'a title',
|
||||||
'signType': 'pdfImageStamp',
|
'signType': 'pdfImageStamp',
|
||||||
'pending': True,
|
'pending': True,
|
||||||
|
'allSignToComplete': False,
|
||||||
|
'userSignFirst': False,
|
||||||
|
'forceAllSign': False,
|
||||||
}
|
}
|
||||||
rsps.post(
|
rsps.post(
|
||||||
'https://esup-signature.invalid/ws/signrequests/new',
|
'https://esup-signature.invalid/ws/signrequests/new',
|
||||||
|
|
Loading…
Reference in New Issue