Skip to content

Commit 843759f

Browse files
authored
remove habname from exchange query (WebOfTrust#128)
1 parent 2a3f482 commit 843759f

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

src/keria/peer/exchanging.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def loadEnds(app):
1818
app.add_route("/identifiers/{name}/exchanges", exnColEnd)
1919

2020
exnColEnd = ExchangeQueryCollectionEnd()
21-
app.add_route("/identifiers/{name}/exchanges/query", exnColEnd)
21+
app.add_route("/exchanges/query", exnColEnd)
2222

2323
exnResEnd = ExchangeResourceEnd()
24-
app.add_route("/identifiers/{name}/exchanges/{said}", exnResEnd)
24+
app.add_route("/exchanges/{said}", exnResEnd)
2525

2626

2727
class ExchangeCollectionEnd:
@@ -83,19 +83,15 @@ def on_post(req, rep, name):
8383
class ExchangeQueryCollectionEnd:
8484

8585
@staticmethod
86-
def on_post(req, rep, name):
86+
def on_post(req, rep):
8787
""" POST endpoint for exchange message collection
8888
8989
Args:
9090
req (Request): falcon HTTP request object
9191
rep (Response): falcon HTTP response object
92-
name (str): human readable alias for AID context
9392
9493
"""
9594
agent = req.context.agent
96-
hab = agent.hby.habByName(name)
97-
if hab is None:
98-
raise falcon.HTTPNotFound(description="name is not a valid reference to an identifier")
9995

10096
try:
10197
body = req.get_media()
@@ -141,23 +137,16 @@ class ExchangeResourceEnd:
141137
""" Exchange message resource endpoint class """
142138

143139
@staticmethod
144-
def on_get(req, rep, name, said):
140+
def on_get(req, rep, said):
145141
"""GET endpoint for exchange message collection
146142
147143
Args:
148144
req (Request): falcon HTTP request object
149145
rep (Response): falcon HTTP response object
150-
name (str): human readable alias for AID context
151146
said (str): qb64 SAID of exchange message to retrieve
152147
153148
"""
154149
agent = req.context.agent
155-
156-
# Get the hab
157-
hab = agent.hby.habByName(name)
158-
if hab is None:
159-
raise falcon.HTTPNotFound(description=f"alias={name} is not a valid reference to an identifier")
160-
161150
serder, pathed = exchanging.cloneMessage(agent.hby, said)
162151

163152
if serder is None:

tests/peer/test_exchanging.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ def test_exchange_end(helpers):
115115
agent.exnseeker.index(exn.said)
116116

117117
body = json.dumps({}).encode("utf-8")
118-
res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body)
118+
res = client.simulate_post(f"/exchanges/query", body=body)
119119
assert res.status_code == 200
120120
assert len(res.json) == 2
121121

122122
body = json.dumps({'filter': {'-i': pre}, 'sort': ['-dt']}).encode("utf-8")
123-
res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body)
123+
res = client.simulate_post(f"/exchanges/query", body=body)
124124
assert res.status_code == 200
125125
assert len(res.json) == 2
126126

@@ -133,15 +133,15 @@ def test_exchange_end(helpers):
133133
assert serder.said == exn.said
134134

135135
body = json.dumps({'filter': {'-i': pre}, 'sort': ['-dt'], 'skip': 1, "limit": 1}).encode("utf-8")
136-
res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body)
136+
res = client.simulate_post(f"/exchanges/query", body=body)
137137
assert res.status_code == 200
138138
assert len(res.json) == 1
139139

140140
ked = res.json[0]['exn']
141141
serder = coring.Serder(ked=ked)
142142
assert serder.said == exn.said
143143

144-
res = client.simulate_get(f"/identifiers/aid1/exchanges/{exn.said}")
144+
res = client.simulate_get(f"/exchanges/{exn.said}")
145145
assert res.status_code == 200
146146
serder = coring.Serder(ked=res.json['exn'])
147147
assert serder.said == exn.said
@@ -176,7 +176,7 @@ def test_exchange_end(helpers):
176176
agent.exnseeker.index(exn.said)
177177

178178
body = json.dumps({'sort': ['-dt']}).encode("utf-8")
179-
res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body)
179+
res = client.simulate_post(f"/exchanges/query", body=body)
180180
assert res.status_code == 200
181181
assert len(res.json) == 3
182182

0 commit comments

Comments
 (0)