Skip to content

Commit

Permalink
Remove base wallet type must be new wallet type restriction (openwall…
Browse files Browse the repository at this point in the history
…et-foundation#3542)

* Remove base wallet type must be new wallet type restriction

Signed-off-by: jamshale <jamiehalebc@gmail.com>

* Remove invalid test

Signed-off-by: jamshale <jamiehalebc@gmail.com>

---------

Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale authored and ff137 committed Feb 27, 2025
1 parent f23dd0c commit 6bc6fc0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 66 deletions.
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

0 comments on commit 6bc6fc0

Please sign in to comment.