From 843759f46d9b35306a6dd0c406e4292105ef6f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lenksj=C3=B6?= <5889538+lenkan@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:38:00 +0100 Subject: [PATCH] remove habname from exchange query (#128) --- src/keria/peer/exchanging.py | 19 ++++--------------- tests/peer/test_exchanging.py | 10 +++++----- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/keria/peer/exchanging.py b/src/keria/peer/exchanging.py index f7797167..42d14027 100644 --- a/src/keria/peer/exchanging.py +++ b/src/keria/peer/exchanging.py @@ -18,10 +18,10 @@ def loadEnds(app): app.add_route("/identifiers/{name}/exchanges", exnColEnd) exnColEnd = ExchangeQueryCollectionEnd() - app.add_route("/identifiers/{name}/exchanges/query", exnColEnd) + app.add_route("/exchanges/query", exnColEnd) exnResEnd = ExchangeResourceEnd() - app.add_route("/identifiers/{name}/exchanges/{said}", exnResEnd) + app.add_route("/exchanges/{said}", exnResEnd) class ExchangeCollectionEnd: @@ -83,19 +83,15 @@ def on_post(req, rep, name): class ExchangeQueryCollectionEnd: @staticmethod - def on_post(req, rep, name): + def on_post(req, rep): """ POST endpoint for exchange message collection Args: req (Request): falcon HTTP request object rep (Response): falcon HTTP response object - name (str): human readable alias for AID context """ agent = req.context.agent - hab = agent.hby.habByName(name) - if hab is None: - raise falcon.HTTPNotFound(description="name is not a valid reference to an identifier") try: body = req.get_media() @@ -141,23 +137,16 @@ class ExchangeResourceEnd: """ Exchange message resource endpoint class """ @staticmethod - def on_get(req, rep, name, said): + def on_get(req, rep, said): """GET endpoint for exchange message collection Args: req (Request): falcon HTTP request object rep (Response): falcon HTTP response object - name (str): human readable alias for AID context said (str): qb64 SAID of exchange message to retrieve """ agent = req.context.agent - - # Get the hab - hab = agent.hby.habByName(name) - if hab is None: - raise falcon.HTTPNotFound(description=f"alias={name} is not a valid reference to an identifier") - serder, pathed = exchanging.cloneMessage(agent.hby, said) if serder is None: diff --git a/tests/peer/test_exchanging.py b/tests/peer/test_exchanging.py index 37f9e022..4e64d9d5 100644 --- a/tests/peer/test_exchanging.py +++ b/tests/peer/test_exchanging.py @@ -115,12 +115,12 @@ def test_exchange_end(helpers): agent.exnseeker.index(exn.said) body = json.dumps({}).encode("utf-8") - res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body) + res = client.simulate_post(f"/exchanges/query", body=body) assert res.status_code == 200 assert len(res.json) == 2 body = json.dumps({'filter': {'-i': pre}, 'sort': ['-dt']}).encode("utf-8") - res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body) + res = client.simulate_post(f"/exchanges/query", body=body) assert res.status_code == 200 assert len(res.json) == 2 @@ -133,7 +133,7 @@ def test_exchange_end(helpers): assert serder.said == exn.said body = json.dumps({'filter': {'-i': pre}, 'sort': ['-dt'], 'skip': 1, "limit": 1}).encode("utf-8") - res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body) + res = client.simulate_post(f"/exchanges/query", body=body) assert res.status_code == 200 assert len(res.json) == 1 @@ -141,7 +141,7 @@ def test_exchange_end(helpers): serder = coring.Serder(ked=ked) assert serder.said == exn.said - res = client.simulate_get(f"/identifiers/aid1/exchanges/{exn.said}") + res = client.simulate_get(f"/exchanges/{exn.said}") assert res.status_code == 200 serder = coring.Serder(ked=res.json['exn']) assert serder.said == exn.said @@ -176,7 +176,7 @@ def test_exchange_end(helpers): agent.exnseeker.index(exn.said) body = json.dumps({'sort': ['-dt']}).encode("utf-8") - res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body) + res = client.simulate_post(f"/exchanges/query", body=body) assert res.status_code == 200 assert len(res.json) == 3