Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix routing in set public did #2288

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions aries_cloudagent/wallet/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,12 @@ async def wallet_set_public_did(request: web.BaseRequest):
)
routing_keys = None
mediator_endpoint = None
mkempa marked this conversation as resolved.
Show resolved Hide resolved
if mediation_record:
routing_keys = mediation_record.routing_keys
mediator_endpoint = mediation_record.endpoint

routing_keys, mediator_endpoint = await route_manager.routing_info(
profile,
mediator_endpoint,
mediation_record,
)

try:
info, attrib_def = await promote_wallet_public_did(
Expand Down
36 changes: 32 additions & 4 deletions aries_cloudagent/wallet/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def setUp(self):
self.did_methods = DIDMethods()
self.context.injector.bind_instance(DIDMethods, self.did_methods)

self.test_mediator_routing_keys = [
"3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRR"
]
self.test_mediator_endpoint = "http://mediator.example.com"

async def test_missing_wallet(self):
self.session_inject[BaseWallet] = None

Expand Down Expand Up @@ -440,6 +445,9 @@ async def test_set_public_did(self):
mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_verkey = async_mock.AsyncMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand Down Expand Up @@ -477,6 +485,9 @@ async def test_set_public_did_no_query_did(self):
async def test_set_public_did_no_ledger(self):
mock_route_manager = async_mock.MagicMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand All @@ -497,6 +508,9 @@ async def test_set_public_did_not_public(self):

mock_route_manager = async_mock.MagicMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand All @@ -516,6 +530,9 @@ async def test_set_public_did_not_found(self):

mock_route_manager = async_mock.MagicMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand All @@ -537,6 +554,9 @@ async def test_set_public_did_x(self):

mock_route_manager = async_mock.MagicMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand Down Expand Up @@ -568,6 +588,9 @@ async def test_set_public_did_no_wallet_did(self):

mock_route_manager = async_mock.MagicMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand Down Expand Up @@ -600,6 +623,9 @@ async def test_set_public_did_update_endpoint(self):
mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_verkey = async_mock.AsyncMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(self.test_mediator_routing_keys, self.test_mediator_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand All @@ -611,7 +637,7 @@ async def test_set_public_did_update_endpoint(self):
self.wallet.set_public_did.return_value = DIDInfo(
self.test_did,
self.test_verkey,
{**DIDPosture.PUBLIC.metadata, "endpoint": "https://endpoint.com"},
{**DIDPosture.PUBLIC.metadata, "endpoint": self.test_mediator_endpoint},
SOV,
ED25519,
)
Expand All @@ -632,9 +658,8 @@ async def test_set_public_did_update_endpoint(self):

async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self):
self.request.query = {"did": self.test_did}
self.context.update_settings(
{"default_endpoint": "https://default_endpoint.com"}
)
default_endpoint = "https://default_endpoint.com"
self.context.update_settings({"default_endpoint": default_endpoint})

Ledger = async_mock.MagicMock()
ledger = Ledger()
Expand All @@ -648,6 +673,9 @@ async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self)
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock(
return_value=None
)
mock_route_manager.routing_info = async_mock.AsyncMock(
return_value=(None, default_endpoint)
)
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
)
Expand Down