From 36fa77f56aa690379d0bad1510c730798848683a Mon Sep 17 00:00:00 2001 From: Rodolfo Miranda Date: Thu, 2 May 2024 19:31:19 -0300 Subject: [PATCH] add JSONDecodeError --- src/keria/app/credentialing.py | 2 +- tests/app/test_credentialing.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/keria/app/credentialing.py b/src/keria/app/credentialing.py index 30e06574..8201b3d7 100644 --- a/src/keria/app/credentialing.py +++ b/src/keria/app/credentialing.py @@ -553,7 +553,7 @@ def on_post(self, req, rep, name): anc = serdering.SerderKERI(sad=httping.getRequiredParam(body, "ixn")) else: anc = serdering.SerderKERI(sad=httping.getRequiredParam(body, "rot")) - except kering.ValidationError as e: + except (kering.ValidationError, json.decoder.JSONDecodeError) as e: rep.status = falcon.HTTP_400 rep.text = e.args[0] return diff --git a/tests/app/test_credentialing.py b/tests/app/test_credentialing.py index 94f3ed9f..c0725153 100644 --- a/tests/app/test_credentialing.py +++ b/tests/app/test_credentialing.py @@ -293,11 +293,6 @@ def test_issue_credential(helpers, seeder): assert result.json == {'description': "name is not a valid reference to an identifier", 'title': '404 Not Found'} - result = client.simulate_post(path="/identifiers/issuer/credentials", body=json.dumps({}).encode("utf-8")) - assert result.status_code == 400 - assert result.json == {'description': "required field 'acdc' missing from request", - 'title': '400 Bad Request'} - result = client.simulate_post(path="/identifiers/issuer/credentials", body=json.dumps(body).encode("utf-8")) op = result.json @@ -309,6 +304,9 @@ def test_issue_credential(helpers, seeder): assert agent.credentialer.complete(creder.said) is True + body["acdc"]["a"]["LEI"] = "ACDC10JSON000197_" + result = client.simulate_post(path="/identifiers/issuer/credentials", body=json.dumps(body).encode("utf-8")) + assert result.status_code == 400 def test_credentialing_ends(helpers, seeder): salt = b'0123456789abcdef'