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

Remove base wallet type must be new wallet type restriction #3542

Merged
merged 4 commits into from
Feb 26, 2025
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
6 changes: 0 additions & 6 deletions acapy_agent/multitenant/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from ...multitenant.base import BaseMultitenantManager
from ...storage.error import StorageError, StorageNotFoundError
from ...utils.endorsement_setup import attempt_auto_author_with_endorser_setup
from ...utils.profiles import subwallet_type_not_same_as_base_wallet_raise_web_exception
from ...wallet.error import WalletSettingsError
from ...wallet.models.wallet_record import WalletRecord, WalletRecordSchema
from ..error import WalletKeyMissingError
Expand Down Expand Up @@ -450,11 +449,6 @@ async def wallet_create(request: web.BaseRequest):

base_wallet_type = context.profile.settings.get("wallet.type")
sub_wallet_type = body.get("wallet_type", base_wallet_type)

subwallet_type_not_same_as_base_wallet_raise_web_exception(
base_wallet_type, sub_wallet_type
)

key_management_mode = body.get("key_management_mode") or WalletRecord.MODE_MANAGED
wallet_key = body.get("wallet_key")
wallet_webhook_urls = body.get("wallet_webhook_urls") or []
Expand Down
50 changes: 0 additions & 50 deletions acapy_agent/multitenant/admin/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,56 +215,6 @@ async def test_wallet_create_tenant_settings(self):
assert mock_multitenant_mgr.get_wallet_profile.called
assert test_module.attempt_auto_author_with_endorser_setup.called

async def test_wallet_create_wallet_type_different_from_base_wallet_raises_403(
self,
):
body = {
"wallet_name": "test",
"default_label": "test_label",
"wallet_type": "askar",
"wallet_key": "test",
"key_management_mode": "managed",
"wallet_webhook_urls": [],
"wallet_dispatch_type": "base",
}
wallet_mock = mock.MagicMock(
serialize=mock.MagicMock(
return_value={
"wallet_id": "test",
"settings": {},
"key_management_mode": body["key_management_mode"],
}
)
)
# wallet_record
mock_multitenant_mgr = mock.AsyncMock(BaseMultitenantManager, autospec=True)
mock_multitenant_mgr.create_wallet = mock.CoroutineMock(return_value=wallet_mock)

mock_multitenant_mgr.create_auth_token = mock.CoroutineMock(
return_value="test_token"
)
mock_multitenant_mgr.get_wallet_profile = mock.CoroutineMock(
return_value=mock.MagicMock()
)
self.profile.context.injector.bind_instance(
BaseMultitenantManager, mock_multitenant_mgr
)
self.request.json = mock.CoroutineMock(return_value=body)

await test_module.wallet_create(self.request)

body["wallet_type"] = "askar-anoncreds"
with self.assertRaises(test_module.web.HTTPForbidden):
await test_module.wallet_create(self.request)

body["wallet_type"] = "indy"
with self.assertRaises(test_module.web.HTTPForbidden):
await test_module.wallet_create(self.request)

body["wallet_type"] = "in_memory"
with self.assertRaises(test_module.web.HTTPForbidden):
await test_module.wallet_create(self.request)

async def test_wallet_create(self):
body = {
"wallet_name": "test",
Expand Down
10 changes: 0 additions & 10 deletions acapy_agent/utils/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ def is_not_anoncreds_profile_raise_web_exception(profile: Profile) -> None:
raise web.HTTPForbidden(reason=ANONCREDS_PROFILE_REQUIRED_MSG)


def subwallet_type_not_same_as_base_wallet_raise_web_exception(
base_wallet_type: str, sub_wallet_type: str
) -> None:
"""Raise a web exception when the subwallet type is not the same as the base wallet type.""" # noqa: E501
if base_wallet_type != sub_wallet_type:
raise web.HTTPForbidden(
reason="Subwallet type must be the same as the base wallet type"
)


async def get_subwallet_profiles_from_storage(root_profile: Profile) -> list[Profile]:
"""Get subwallet profiles from storage."""
subwallet_profiles = []
Expand Down
Loading