Skip to content

Commit 224b93e

Browse files
committed
feat: enable creation of DIDs for all registered methods
To leverage the recent addition of the `DIDMethods` registry: * Relax condition on did format for the `POST /wallet/did` endpoint * Validate new DIDs parameters using `DIDMethods` in Askar and InMemory profiles validate new DIDs parameters Signed-off-by: Clément Humbert <clement.humbert@sicpa.com>
1 parent a28441a commit 224b93e

26 files changed

Lines changed: 312 additions & 71 deletions

File tree

aries_cloudagent/core/tests/test_conductor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from ...utils.stats import Collector
3737
from ...version import __version__
3838
from ...wallet.base import BaseWallet
39-
from ...wallet.did_method import SOV
39+
from ...wallet.did_method import SOV, DIDMethods
4040
from ...wallet.key_type import ED25519
4141
from .. import conductor as test_module
4242

@@ -87,6 +87,7 @@ async def build_context(self) -> InjectionContext:
8787
context.injector.bind_instance(ProfileManager, InMemoryProfileManager())
8888
context.injector.bind_instance(ProtocolRegistry, ProtocolRegistry())
8989
context.injector.bind_instance(BaseWireFormat, self.wire_format)
90+
context.injector.bind_instance(DIDMethods, DIDMethods())
9091
context.injector.bind_instance(DIDResolver, DIDResolver([]))
9192
context.injector.bind_instance(EventBus, MockEventBus())
9293
return context

aries_cloudagent/ledger/tests/test_indy_vdr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
@pytest.fixture()
3030
def ledger():
31-
profile = InMemoryProfile.test_profile()
31+
profile = InMemoryProfile.test_profile(bind={DIDMethods: DIDMethods()})
3232
ledger = IndyVdrLedger(IndyVdrLedgerPool("test-ledger"), profile)
3333

3434
async def open():

aries_cloudagent/messaging/jsonld/tests/test_routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ....resolver.did_resolver import DIDResolver
1515
from ....vc.ld_proofs.document_loader import DocumentLoader
1616
from ....wallet.base import BaseWallet
17-
from ....wallet.did_method import SOV
17+
from ....wallet.did_method import SOV, DIDMethods
1818
from ....wallet.error import WalletError
1919
from ....wallet.key_type import ED25519
2020
from ..error import (
@@ -274,6 +274,7 @@ async def setUp(self):
274274
self.context.profile.context.injector.bind_instance(
275275
DocumentLoader, custom_document_loader
276276
)
277+
self.context.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
277278
self.did_info = await (await self.context.session()).wallet.create_local_did(
278279
SOV, ED25519
279280
)

aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .....storage.error import StorageNotFoundError
2424
from .....transport.inbound.receipt import MessageReceipt
2525
from .....wallet.base import DIDInfo
26-
from .....wallet.did_method import SOV
26+
from .....wallet.did_method import SOV, DIDMethods
2727
from .....wallet.error import WalletNotFoundError
2828
from .....wallet.in_memory import InMemoryWallet
2929
from .....wallet.key_type import ED25519
@@ -93,6 +93,7 @@ async def setUp(self):
9393
BaseCache: InMemoryCache(),
9494
OobMessageProcessor: self.oob_mock,
9595
RouteManager: self.route_manager,
96+
DIDMethods: DIDMethods(),
9697
},
9798
)
9899
self.context = self.profile.context

aries_cloudagent/protocols/coordinate_mediation/v1_0/handlers/tests/test_mediation_request_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from ...models.mediation_record import MediationRecord
1414

1515
from ..mediation_request_handler import MediationRequestHandler
16+
from ......wallet.did_method import DIDMethods
1617

1718
TEST_CONN_ID = "conn-id"
1819
TEST_VERKEY = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx"
@@ -24,6 +25,7 @@ class TestMediationRequestHandler(AsyncTestCase):
2425
async def setUp(self):
2526
"""setup dependencies of messaging"""
2627
self.context = RequestContext.test_context()
28+
self.context.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
2729
self.session = await self.context.session()
2830
self.context.message = MediationRequest()
2931
self.context.connection_ready = True

aries_cloudagent/protocols/coordinate_mediation/v1_0/tests/test_mediation_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ..messages.mediate_grant import MediationGrant
2727
from ..messages.mediate_request import MediationRequest
2828
from ..models.mediation_record import MediationRecord
29+
from .....wallet.did_method import DIDMethods
2930

3031
TEST_CONN_ID = "conn-id"
3132
TEST_THREAD_ID = "thread-id"
@@ -42,7 +43,9 @@
4243
def profile() -> Iterable[Profile]:
4344
"""Fixture for profile used in tests."""
4445
# pylint: disable=W0621
45-
yield InMemoryProfile.test_profile(bind={EventBus: MockEventBus()})
46+
yield InMemoryProfile.test_profile(
47+
bind={EventBus: MockEventBus(), DIDMethods: DIDMethods()}
48+
)
4649

4750

4851
@pytest.fixture

aries_cloudagent/protocols/coordinate_mediation/v1_0/tests/test_routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
from .....storage.error import StorageError, StorageNotFoundError
77
from ..models.mediation_record import MediationRecord
88
from ..route_manager import RouteManager
9+
from .....wallet.did_method import DIDMethods
910

1011

1112
class TestCoordinateMediationRoutes(AsyncTestCase):
1213
def setUp(self):
1314
self.profile = InMemoryProfile.test_profile()
15+
self.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
1416
self.context = AdminRequestContext.test_context(profile=self.profile)
1517
self.outbound_message_router = async_mock.CoroutineMock()
1618
self.request_dict = {

aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_complete_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
from ...messages.problem_report_reason import ProblemReportReason
1111

1212
from .. import complete_handler as test_module
13+
from ......wallet.did_method import DIDMethods
1314

1415

1516
@pytest.fixture()
1617
def request_context() -> RequestContext:
1718
ctx = RequestContext.test_context()
19+
ctx.injector.bind_instance(DIDMethods, DIDMethods())
1820
ctx.message_receipt = MessageReceipt()
1921
yield ctx
2022

aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_invitation_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010
from ...handlers.invitation_handler import InvitationHandler
1111
from ...messages.problem_report_reason import ProblemReportReason
12+
from ......wallet.did_method import DIDMethods
1213

1314

1415
@pytest.fixture()
1516
def request_context() -> RequestContext:
1617
ctx = RequestContext.test_context()
18+
ctx.injector.bind_instance(DIDMethods, DIDMethods())
1719
ctx.message_receipt = MessageReceipt()
1820
yield ctx
1921

aries_cloudagent/protocols/didexchange/v1_0/handlers/tests/test_request_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Service,
1010
)
1111
from ......core.in_memory import InMemoryProfile
12-
from ......wallet.did_method import SOV
12+
from ......wallet.did_method import SOV, DIDMethods
1313
from ......wallet.key_type import ED25519
1414
from ......messaging.decorators.attach_decorator import AttachDecorator
1515
from ......messaging.request_context import RequestContext
@@ -76,6 +76,7 @@ async def setUp(self):
7676
"debug.auto_accept_requests_public": True,
7777
}
7878
)
79+
self.session.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
7980

8081
self.conn_rec = conn_record.ConnRecord(
8182
my_did="55GkHamhTU1ZbTbV2ab9DE",

0 commit comments

Comments
 (0)