esup_signature: add workflows endpoint (#79131)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7212c9056d
commit
faebc78066
|
@ -409,3 +409,14 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
response = HttpResponse(resp.content, content_type=resp.headers['Content-Type'])
|
||||
response['Content-Disposition'] = resp.headers['Content-Disposition']
|
||||
return response
|
||||
|
||||
@endpoint(
|
||||
methods=['get'],
|
||||
description=_('List available workflows'),
|
||||
)
|
||||
def workflows(self, request, **kwargs):
|
||||
def add_text(wf):
|
||||
wf['text'] = wf['description']
|
||||
return wf
|
||||
|
||||
return {'data': [add_text(wf) for wf in self._call('ws/workflows/all')]}
|
||||
|
|
|
@ -155,3 +155,19 @@ def test_forced_headers(app, connector):
|
|||
app.get('/esup-signature/esup-signature/get-last-file?signrequests_id=1')
|
||||
headers = rsps.calls[0].request.headers
|
||||
assert headers['X-Foo'] == 'bar'
|
||||
|
||||
|
||||
def test_workflows(app, connector):
|
||||
with responses.RequestsMock() as rsps:
|
||||
rsps.get(
|
||||
'https://esup-signature.invalid/ws/workflows/all',
|
||||
status=200,
|
||||
json=[{'id': 0, 'description': 'foo'}, {'id': 1, 'description': 'bar'}],
|
||||
)
|
||||
resp = app.get('/esup-signature/esup-signature/workflows')
|
||||
json_resp = resp.json
|
||||
assert json_resp['err'] == 0
|
||||
assert json_resp['data'] == [
|
||||
{'id': 0, 'description': 'foo', 'text': 'foo'},
|
||||
{'id': 1, 'description': 'bar', 'text': 'bar'},
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue