Skip to content

Commit

Permalink
Merge pull request #2803 from jamshale/feat/2792
Browse files Browse the repository at this point in the history
Get and create anoncreds profile when using anoncreds subwallet
  • Loading branch information
ianco committed Feb 21, 2024
2 parents cfa8cb5 + 5ea2fa0 commit 8689339
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions aries_cloudagent/multitenant/askar_profile_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import Iterable, Optional, cast

from ..askar.profile_anon import AskarAnoncredsProfile
from ..askar.profile import AskarProfile
from ..config.injection_context import InjectionContext
from ..config.wallet import wallet_config
Expand Down Expand Up @@ -104,6 +105,14 @@ async def get_wallet_profile(

assert self._multitenant_profile.opened

# return anoncreds profile if explicitly set as wallet type
if profile_context.settings.get("wallet.type") == "askar-anoncreds":
return AskarAnoncredsProfile(
self._multitenant_profile.opened,
profile_context,
profile_id=wallet_record.wallet_id,
)

return AskarProfile(
self._multitenant_profile.opened,
profile_context,
Expand Down
36 changes: 36 additions & 0 deletions aries_cloudagent/multitenant/tests/test_askar_profile_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,42 @@ def side_effect(context, provision):
== wallet_record.wallet_id
)

async def test_get_anoncreds_wallet_profile_should_open_store_and_return_anoncreds_profile(
self,
):
askar_profile_mock_name = "AskarProfile"
wallet_record = WalletRecord(
wallet_id="test",
settings={
"wallet.recreate": True,
"wallet.seed": "test_seed",
"wallet.name": "test_name",
"wallet.type": "askar-anoncreds",
"wallet.rekey": "test_rekey",
},
)

with mock.patch(
"aries_cloudagent.multitenant.askar_profile_manager.wallet_config"
) as wallet_config, mock.patch(
"aries_cloudagent.multitenant.askar_profile_manager.AskarAnoncredsProfile",
) as AskarAnoncredsProfile:
sub_wallet_profile_context = InjectionContext()
sub_wallet_profile = AskarAnoncredsProfile(None, None)
sub_wallet_profile.context.copy.return_value = sub_wallet_profile_context

def side_effect(context, provision):
sub_wallet_profile.name = askar_profile_mock_name
return sub_wallet_profile, None

wallet_config.side_effect = side_effect

await self.manager.get_wallet_profile(self.profile.context, wallet_record)

AskarAnoncredsProfile.assert_called_with(
sub_wallet_profile.opened, sub_wallet_profile_context, profile_id="test"
)

async def test_get_wallet_profile_should_create_profile(self):
wallet_record = WalletRecord(wallet_id="test", settings={})
create_profile_stub = asyncio.Future()
Expand Down

0 comments on commit 8689339

Please sign in to comment.