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

did-exchange implicit request pthid update & invitation key verification #1599

Merged
merged 30 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6103967
update pthid
shaangill025 Jan 13, 2022
dcb5cfd
format fix
shaangill025 Jan 13, 2022
a142c9d
updates
shaangill025 Jan 18, 2022
6ea511f
Merge branch 'main' into did_exchange
shaangill025 Jan 20, 2022
acac74d
Merge branch 'main' into did_exchange
shaangill025 Jan 21, 2022
4c1a1df
Merge branch 'main' into did_exchange
swcurran Feb 8, 2022
9c85423
Merge branch 'main' into did_exchange
shaangill025 Feb 8, 2022
9da4918
Merge branch 'main' into did_exchange
shaangill025 Mar 18, 2022
a26ff55
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Mar 22, 2022
3ecbdeb
Merge branch 'did_exchange' of https://github.com/shaangill025/aries-…
shaangill025 Mar 22, 2022
0b62eb3
verify signature from kid
shaangill025 Mar 24, 2022
790ab5e
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Mar 24, 2022
b661cc0
Merge branch 'main' into did_exchange
shaangill025 Mar 29, 2022
aabb96e
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Mar 30, 2022
84e407e
Merge branch 'did_exchange' of https://github.com/shaangill025/aries-…
shaangill025 Mar 30, 2022
7a9295e
use ursa-bbs-signatures 1.0.1
shaangill025 Mar 30, 2022
3849d51
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Mar 30, 2022
ed19dcc
revert locking ursa-bbs-signature package - 1.0.2 pypi removed
shaangill025 Mar 30, 2022
29736df
Merge branch 'main' into did_exchange
shaangill025 Mar 31, 2022
ff5337e
Merge branch 'main' into did_exchange
shaangill025 Apr 1, 2022
9c998e0
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Apr 1, 2022
2afaae8
Merge branch 'did_exchange' of https://github.com/shaangill025/aries-…
shaangill025 Apr 1, 2022
91d49be
retrigger check
shaangill025 Apr 1, 2022
ab22fcb
Merge branch 'main' into did_exchange
ianco Apr 5, 2022
96a0404
Merge branch 'main' into did_exchange
ianco Apr 5, 2022
40ae949
Merge branch 'main' into did_exchange
ianco Apr 6, 2022
9ce96be
update attach_decorator verify method
shaangill025 Apr 6, 2022
e11f021
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Apr 6, 2022
1fbc77a
Merge branch 'did_exchange' of https://github.com/shaangill025/aries-…
shaangill025 Apr 6, 2022
3fae679
Merge branch 'main' into did_exchange
shaangill025 Apr 7, 2022
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
27 changes: 20 additions & 7 deletions aries_cloudagent/protocols/didexchange/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import json
import logging
import pydid

from pydid import BaseDIDDocument as ResolvedDocument

from ....connections.models.conn_record import ConnRecord
from ....connections.models.diddoc import DIDDoc
Expand All @@ -12,6 +15,8 @@
from ....messaging.decorators.attach_decorator import AttachDecorator
from ....messaging.responder import BaseResponder
from ....multitenant.base import BaseMultitenantManager
from ....resolver.base import ResolverError
from ....resolver.did_resolver import DIDResolver
from ....storage.error import StorageNotFoundError
from ....transport.inbound.receipt import MessageReceipt
from ....wallet.base import BaseWallet
Expand Down Expand Up @@ -296,14 +301,22 @@ async def create_request(
filter(None, [base_mediation_record, mediation_record])
),
)
if (
conn_rec.their_public_did is not None
and conn_rec.their_public_did.startswith("did:")
):
if conn_rec.their_public_did is not None:
qualified_did = conn_rec.their_public_did
else:
qualified_did = f"did:sov:{conn_rec.their_public_did}"
pthid = conn_rec.invitation_msg_id or qualified_did
if not conn_rec.their_public_did.startswith("did:"):
qualified_did = f"did:sov:{conn_rec.their_public_did}"
resolver = self._profile.inject(DIDResolver)
try:
doc_dict: dict = await resolver.resolve(self._profile, qualified_did)
doc: ResolvedDocument = pydid.deserialize_document(
doc_dict, strict=True
)
did_url = doc.service[0].id
shaangill025 marked this conversation as resolved.
Show resolved Hide resolved
except ResolverError as error:
raise DIDXManagerError(
"Failed to resolve public DID in invitation"
) from error
pthid = conn_rec.invitation_msg_id or did_url
attach = AttachDecorator.data_base64(did_doc.serialize())
async with self.profile.session() as session:
wallet = session.inject(BaseWallet)
Expand Down
32 changes: 32 additions & 0 deletions aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

from asynctest import mock as async_mock, TestCase as AsyncTestCase
from pydid import DIDDocument

from .....cache.base import BaseCache
from .....cache.in_memory import InMemoryCache
Expand All @@ -18,6 +19,9 @@
from .....messaging.decorators.attach_decorator import AttachDecorator
from .....multitenant.base import BaseMultitenantManager
from .....multitenant.manager import MultitenantManager
from .....resolver.base import ResolverError
from .....resolver.did_resolver import DIDResolver
from .....resolver.tests import DOC
from .....storage.error import StorageNotFoundError
from .....transport.inbound.receipt import MessageReceipt
from .....wallet.did_info import DIDInfo
Expand Down Expand Up @@ -102,6 +106,10 @@ async def setUp(self):
return_value=TestConfig.test_endpoint
)
self.context.injector.bind_instance(BaseLedger, self.ledger)
self.resolver = async_mock.MagicMock()
did_doc = DIDDocument.deserialize(DOC)
self.resolver.resolve = async_mock.CoroutineMock(return_value=did_doc)
self.context.injector.bind_instance(DIDResolver, self.resolver)

self.multitenant_mgr = async_mock.MagicMock(MultitenantManager, autospec=True)
self.context.injector.bind_instance(
Expand Down Expand Up @@ -266,6 +274,27 @@ async def test_create_request_implicit_use_public_did(self):

assert info_public.did == conn_rec.my_did

async def test_create_request_implicit_resolver_error(self):
async with self.profile.session() as session:
await session.wallet.create_public_did(
DIDMethod.SOV,
KeyType.ED25519,
)
with async_mock.patch.object(
self.resolver,
"resolve",
async_mock.CoroutineMock(side_effect=ResolverError()),
):
with self.assertRaises(DIDXManagerError) as ctx:
conn_rec = await self.manager.create_request_implicit(
their_public_did=TestConfig.test_target_did,
my_label=None,
my_endpoint=None,
use_public_did=True,
alias="Tester",
)
assert "Failed to resolve public DID in invitation" in str(ctx.exception)

async def test_create_request_implicit_no_public_did(self):
with self.assertRaises(WalletError) as context:
await self.manager.create_request_implicit(
Expand All @@ -292,6 +321,7 @@ async def test_create_request(self):
)
),
save=async_mock.CoroutineMock(),
their_public_did=None,
)

with async_mock.patch.object(
Expand Down Expand Up @@ -345,6 +375,7 @@ async def test_create_request_multitenant(self):
)
),
save=async_mock.CoroutineMock(),
their_public_did=None,
)
)

Expand Down Expand Up @@ -419,6 +450,7 @@ async def test_create_request_my_endpoint(self):
)
),
save=async_mock.CoroutineMock(),
their_public_did=None,
)

with async_mock.patch.object(
Expand Down