From ed9a4a29863af8d17bffbaf218ad11b4eaef8ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20S=C3=A9chet?= Date: Tue, 5 Jul 2022 11:21:44 +0200 Subject: [PATCH] toulouse_axel: Forbid blank NameID for invoices endpoint (#66974) --- passerelle/contrib/toulouse_axel/models.py | 2 +- tests/test_toulouse_axel.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/passerelle/contrib/toulouse_axel/models.py b/passerelle/contrib/toulouse_axel/models.py index 2713bb8a..e71f9df2 100644 --- a/passerelle/contrib/toulouse_axel/models.py +++ b/passerelle/contrib/toulouse_axel/models.py @@ -747,7 +747,7 @@ class ToulouseAxel(BaseResource): example_pattern='{regie_id}/invoices', description=_("Get invoices to pay"), parameters={ - 'NameID': {'description': _('Publik ID')}, + 'NameID': {'description': _('Publik ID'), 'blank': False}, 'regie_id': {'description': _('Regie identifier'), 'example_value': '42-PERISCOL'}, }, ) diff --git a/tests/test_toulouse_axel.py b/tests/test_toulouse_axel.py index b773f6e6..53ea46ea 100644 --- a/tests/test_toulouse_axel.py +++ b/tests/test_toulouse_axel.py @@ -2063,6 +2063,10 @@ def test_invoices_endpoint_axel_error(app, resource): assert resp.json['err_desc'] == "Axel error: FooBar" assert resp.json['err'] == 'error' + resp = app.get('/toulouse-axel/test/regie/MAREGIE/invoices?NameID=', status=400) + assert 'InvalidParameterValue' in resp.json['err_class'] + assert resp.json['err'] == 1 + def test_invoices_endpoint_no_result(app, resource): resp = app.get('/toulouse-axel/test/regie/MAREGIE/invoices?NameID=yyy')