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

Get and create anoncreds profile when using anoncreds subwallet #2803

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 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
Loading