Skip to content

Commit

Permalink
Merge branch 'hyperledger:main' into per_tenant_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
shaangill025 authored Jun 1, 2023
2 parents 0d73bd8 + a1ec0b7 commit 585ccc4
Show file tree
Hide file tree
Showing 91 changed files with 2,500 additions and 444 deletions.
2 changes: 1 addition & 1 deletion aries_cloudagent/multitenant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def create_wallet(
public_did_info = await wallet.get_public_did()

if public_did_info:
await profile.inject(RouteManager).route_public_did(
await profile.inject(RouteManager).route_verkey(
profile, public_did_info.verkey
)
except Exception:
Expand Down
8 changes: 4 additions & 4 deletions aries_cloudagent/multitenant/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async def test_create_wallet_fails_if_wallet_name_exists(self):

async def test_create_wallet_saves_wallet_record_creates_profile(self):
mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_public_did = async_mock.CoroutineMock()
mock_route_manager.route_verkey = async_mock.CoroutineMock()
self.context.injector.bind_instance(RouteManager, mock_route_manager)

with async_mock.patch.object(
Expand All @@ -232,7 +232,7 @@ async def test_create_wallet_saves_wallet_record_creates_profile(self):
{"wallet.key": "test_key"},
provision=True,
)
mock_route_manager.route_public_did.assert_not_called()
mock_route_manager.route_verkey.assert_not_called()
assert isinstance(wallet_record, WalletRecord)
assert wallet_record.wallet_name == "test_wallet"
assert wallet_record.key_management_mode == WalletRecord.MODE_MANAGED
Expand All @@ -248,7 +248,7 @@ async def test_create_wallet_adds_wallet_route(self):
)

mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_public_did = async_mock.CoroutineMock()
mock_route_manager.route_verkey = async_mock.CoroutineMock()

with async_mock.patch.object(
WalletRecord, "save"
Expand All @@ -267,7 +267,7 @@ async def test_create_wallet_adds_wallet_route(self):
WalletRecord.MODE_MANAGED,
)

mock_route_manager.route_public_did.assert_called_once_with(
mock_route_manager.route_verkey.assert_called_once_with(
get_wallet_profile.return_value, did_info.verkey
)

Expand Down
10 changes: 8 additions & 2 deletions aries_cloudagent/protocols/connections/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def create_invitation(

# Add mapping for multitenant relaying.
# Mediation of public keys is not supported yet
await self._route_manager.route_public_did(self.profile, public_did.verkey)
await self._route_manager.route_verkey(self.profile, public_did.verkey)

else:
# Create connection record
Expand Down Expand Up @@ -1088,7 +1088,13 @@ async def get_connection_targets(

targets = await self.fetch_connection_targets(connection)

await entry.set_result([row.serialize() for row in targets], 3600)
if connection.state == ConnRecord.State.COMPLETED.rfc160:
# Only set cache if connection has reached completed state
# Otherwise, a replica that participated early in exchange
# may have bad data set in cache.
await entry.set_result(
[row.serialize() for row in targets], 3600
)
else:
targets = await self.fetch_connection_targets(connection)
return targets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def test_create_invitation_non_multi_use_invitation_fails_on_reuse(self):
async def test_create_invitation_public(self):
self.context.update_settings({"public_invites": True})

self.route_manager.route_public_did = async_mock.CoroutineMock()
self.route_manager.route_verkey = async_mock.CoroutineMock()
with async_mock.patch.object(
InMemoryWallet, "get_public_did", autospec=True
) as mock_wallet_get_public_did:
Expand All @@ -163,7 +163,7 @@ async def test_create_invitation_public(self):

assert connect_record
assert connect_invite.did.endswith(self.test_did)
self.route_manager.route_public_did.assert_called_once_with(
self.route_manager.route_verkey.assert_called_once_with(
self.profile, self.test_verkey
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ async def route_invitation(

raise ValueError("Expected connection to have invitation_key")

async def route_public_did(self, profile: Profile, verkey: str):
async def route_verkey(self, profile: Profile, verkey: str):
"""Establish routing for a public DID."""
return await self._route_for_key(profile, verkey, skip_if_exists=True)

async def route_public_did(self, profile: Profile, verkey: str):
"""Establish routing for a public DID.
[DEPRECATED] Establish routing for a public DID. Use route_verkey() instead.
"""
return await self._route_for_key(profile, verkey, skip_if_exists=True)

async def route_static(
self,
profile: Profile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ async def test_route_public_did(profile: Profile, route_manager: RouteManager):
)


@pytest.mark.asyncio
async def test_route_verkey(profile: Profile, route_manager: RouteManager):
await route_manager.route_verkey(profile, "test-verkey")
route_manager._route_for_key.assert_called_once_with(
profile, "test-verkey", skip_if_exists=True
)


@pytest.mark.asyncio
async def test_route_static(
profile: Profile, route_manager: RouteManager, conn_record: ConnRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ async def store_credential(
raise V20CredFormatError(f"Received invalid credential: {result}")

# Saving expanded type as a cred_tag
expanded = jsonld.expand(cred_dict)
expanded = jsonld.expand(cred_dict, options={"documentLoader": document_loader})
types = JsonLdProcessor.get_values(
expanded[0],
"@type",
Expand Down
9 changes: 9 additions & 0 deletions aries_cloudagent/protocols/out_of_band/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ async def create_invitation(
endpoint=my_endpoint,
routing_keys=routing_keys,
).serialize()
# Need to make sure the created key is routed by the base wallet
await self._route_manager.route_verkey(
self.profile, connection_key.verkey
)

routing_keys = [
key
Expand Down Expand Up @@ -543,6 +547,11 @@ async def receive_invitation(
endpoint=self.profile.settings.get("default_endpoint"),
routing_keys=[],
).serialize()

# Need to make sure the created key is routed by the base wallet
await self._route_manager.route_verkey(
self.profile, connection_key.verkey
)
await oob_record.save(session)

await self._process_request_attach(oob_record)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ def create_vcrecord(self, cred_dict: dict) -> VCRecord:
if type(schemas) is dict:
schemas = [schemas]
schema_ids = [schema.get("id") for schema in schemas]
expanded = jsonld.expand(cred_dict)
document_loader = self.profile.inject(DocumentLoader)
expanded = jsonld.expand(cred_dict, options={"documentLoader": document_loader})
types = JsonLdProcessor.get_values(
expanded[0],
"@type",
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/wallet/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ async def promote_wallet_public_did(

# Route the public DID
route_manager = profile.inject(RouteManager)
await route_manager.route_public_did(profile, info.verkey)
await route_manager.route_verkey(profile, info.verkey)

return info, attrib_def

Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/wallet/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ async def test_set_public_did(self):
self.profile.context.injector.bind_instance(BaseLedger, ledger)

mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_public_did = async_mock.AsyncMock()
mock_route_manager.route_verkey = async_mock.AsyncMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
Expand Down Expand Up @@ -587,7 +587,7 @@ async def test_set_public_did_update_endpoint(self):
self.profile.context.injector.bind_instance(BaseLedger, ledger)

mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_public_did = async_mock.AsyncMock()
mock_route_manager.route_verkey = async_mock.AsyncMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock()
mock_route_manager.__aenter__ = async_mock.AsyncMock(
return_value=mock_route_manager
Expand Down Expand Up @@ -633,7 +633,7 @@ async def test_set_public_did_update_endpoint_use_default_update_in_wallet(self)
self.profile.context.injector.bind_instance(BaseLedger, ledger)

mock_route_manager = async_mock.MagicMock()
mock_route_manager.route_public_did = async_mock.AsyncMock()
mock_route_manager.route_verkey = async_mock.AsyncMock()
mock_route_manager.mediation_record_if_id = async_mock.AsyncMock(
return_value=None
)
Expand Down
12 changes: 6 additions & 6 deletions demo/AgentTracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Environment variables:
```
TRACE_ENABLED Flag to enable tracing
TRACE_TARGET_URL Host:port of endpoint to log trace events (e.g. fluentd:8088)
TRACE_TARGET_URL Host:port of endpoint to log trace events (e.g. logstash:9700)
DOCKER_NET Docker network to join (must be used if EFK stack is running in docker)
DOCKER_NET Docker network to join (must be used if ELK stack is running in docker)
TRACE_TAG Tag to be included in all logged trace events
```
Expand Down Expand Up @@ -83,16 +83,16 @@ Faber | Connected

When `Exchange Tracing` is `ON`, all exchanges will include tracing.

## Logging Trace Events to an EFK Stack
## Logging Trace Events to an ELK Stack

You can use the `EFK` stack in the [EFK sub-directory](./EFK-stack) as a target for trace events, just start the EFK stack using the docker-compose file and then in two separate bash shells, startup the demo as follows:
You can use the `ELK` stack in the [ELK Stack sub-directory](./elk-stack) as a target for trace events, just start the ELK stack using the docker-compose file and then in two separate bash shells, startup the demo as follows:

```bash
DOCKER_NET=efk-stack_efk_net TRACE_TARGET_URL=fluentd:8088 ./run_demo faber --trace-http
DOCKER_NET=elknet TRACE_TARGET_URL=logstash:9700 ./run_demo faber --trace-http
```

```bash
DOCKER_NET=efk-stack_efk_net TRACE_TARGET_URL=fluentd:8088 ./run_demo alice --trace-http
DOCKER_NET=elknet TRACE_TARGET_URL=logstash:9700 ./run_demo alice --trace-http
```

## Hooking into event messaging
Expand Down
99 changes: 0 additions & 99 deletions demo/EFK-stack/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions demo/EFK-stack/docker-compose.yml

This file was deleted.

Loading

0 comments on commit 585ccc4

Please sign in to comment.