Skip to content

Commit

Permalink
feat: only expose iurls as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal committed Nov 8, 2024
1 parent 5a221d9 commit 30140bc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
35 changes: 18 additions & 17 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,27 +1332,28 @@ def recur(self, tyme, deeds=None):

class ConfigResourceEnd:

""" Config GET endpoint
Parameters:
req (Request): falcon.Request HTTP request
rep (Response): falcon.Response HTTP response
---
summary: Retrieve agent configuration
description: Retrieve agent configuration file as JSON
tags:
- Config
responses:
200:
description: Configuration dict as JSON
"""
@staticmethod
def on_get(req, rep):
""" Config GET endpoint
Parameters:
req (Request): falcon.Request HTTP request
rep (Response): falcon.Response HTTP response
---
summary: Retrieve agent configuration
description: Retrieve agent configuration (only necessary fields are exposed)
tags:
- Config
responses:
200:
description: Subset of configuration dict as JSON
"""
agent = req.context.agent
config = agent.hby.cf.get()
subset = {key: config[key] for key in ["iurls"] if key in config}

rep.status = falcon.HTTP_200
rep.content_type = "application/json"
rep.data = json.dumps(config).encode("utf-8")
rep.data = json.dumps(subset).encode("utf-8")
15 changes: 10 additions & 5 deletions tests/app/test_agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def test_load_tocks_config(helpers):
"dt": "2022-01-20T12:57:59.823350+00:00",
"curls": ["http://127.0.0.1:3902/"]
},
"iurls": [
"http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller&tag=witness"
],
"tocks": {
"initer": 0.0,
"escrower": 1.0
Expand Down Expand Up @@ -359,6 +362,9 @@ def test_oobi_ends(seeder, helpers):
result = client.simulate_post(path="/oobi", body=b)
assert result.status == falcon.HTTP_501

# initiated from keria.json config file (iurls), so remove
oobiery.hby.db.oobis.rem(keys=("http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller&tag=witness",))

data = dict(url="http://127.0.0.1:5644/oobi/E6Dqo6tHmYTuQ3Lope4mZF_4hBoGJl93cBHRekr_iD_A/witness/")
b = json.dumps(data).encode("utf-8")
result = client.simulate_post(path="/oobi", body=b)
Expand Down Expand Up @@ -714,8 +720,7 @@ def test_config_ends(helpers):
app.add_route("/config", configEnd)
res = client.simulate_get(path="/config")
assert res.status == falcon.HTTP_200
assert res.json == {'dt': '2022-01-20T12:57:59.823350+00:00',
'keria': {'dt': '2022-01-20T12:57:59.823350+00:00', 'curls': ['http://127.0.0.1:3902/']},
'EK35JRNdfVkO4JwhXaSTdV4qzB_ibk_tGJmSVcY4pZqx': {'dt': '2022-01-20T12:57:59.823350+00:00', 'curls': ['http://127.0.0.1:3902/']},
'EI7AkI40M11MS7lkTCb10JC9-nDt-tXwQh44OHAFlv_9': {'dt': '2022-01-20T12:57:59.823350+00:00', 'curls': ['http://127.0.0.1:3902/']},
'tocks': {'initer': 0, 'escrower': 1}}
assert res.json == {'iurls':
['http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller&tag=witness']}

agent.cf
3 changes: 2 additions & 1 deletion tests/app/test_specing.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/scripts/keri/cf/main/keria.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"dt": "2022-01-20T12:57:59.823350+00:00",
"curls": ["http://127.0.0.1:3902/"]
},
"iurls": [
"http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller&tag=witness"
],
"tocks": {
"initer": 0.0,
"escrower": 1.0
Expand Down

0 comments on commit 30140bc

Please sign in to comment.