Skip to content

Commit

Permalink
fix: endpoint attrib json object with one top level key "endpoint"
Browse files Browse the repository at this point in the history
Signed-off-by: Char Howland <[email protected]>
  • Loading branch information
cjhowland authored and ryjones committed Sep 9, 2022
1 parent 13110bf commit 981cc6d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions aries_cloudagent/ledger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ async def _construct_attr_json(
if all_exist_endpoints:
all_exist_endpoints[endpoint_type.indy] = endpoint
all_exist_endpoints["routingKeys"] = routing_keys
attr_json = json.dumps(all_exist_endpoints)
attr_json = json.dumps({"endpoint": all_exist_endpoints})

else:
endpoint_dict = {endpoint_type.indy: endpoint}
endpoint_dict["routingKeys"] = routing_keys
attr_json = json.dumps(endpoint_dict)
attr_json = json.dumps({"endpoint": endpoint_dict})

return attr_json

Expand Down
14 changes: 9 additions & 5 deletions aries_cloudagent/ledger/tests/test_indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2312,8 +2312,10 @@ async def test_construct_attr_json_with_routing_keys(self, mock_close, mock_open
)
assert attr_json == json.dumps(
{
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
"endpoint": {
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
}
}
)

Expand All @@ -2333,9 +2335,11 @@ async def test_construct_attr_json_with_routing_keys_all_exist_endpoints(
)
assert attr_json == json.dumps(
{
"profile": "https://endpoint/profile",
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
"endpoint": {
"profile": "https://endpoint/profile",
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
}
}
)

Expand Down
34 changes: 21 additions & 13 deletions aries_cloudagent/ledger/tests/test_indy_vdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,40 +615,48 @@ async def test_update_endpoint_for_did(
{"profile": "https://endpoint/profile"},
["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
{
"profile": "https://endpoint/profile",
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
"endpoint": {
"profile": "https://endpoint/profile",
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
}
},
),
(
{"profile": "https://endpoint/profile"},
None,
{
"profile": "https://endpoint/profile",
"endpoint": "https://url",
"routingKeys": [],
"endpoint": {
"profile": "https://endpoint/profile",
"endpoint": "https://url",
"routingKeys": [],
}
},
),
(
None,
["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
{
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
"endpoint": {
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
}
},
),
(None, None, {"endpoint": "https://url", "routingKeys": []}),
(None, None, {"endpoint": {"endpoint": "https://url", "routingKeys": []}}),
(
{
"profile": "https://endpoint/profile",
"spec_divergent_endpoint": "https://endpoint",
},
["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
{
"profile": "https://endpoint/profile",
"spec_divergent_endpoint": "https://endpoint",
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
"endpoint": {
"profile": "https://endpoint/profile",
"spec_divergent_endpoint": "https://endpoint",
"endpoint": "https://url",
"routingKeys": ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"],
}
},
),
],
Expand Down

0 comments on commit 981cc6d

Please sign in to comment.