diff --git a/acapy_agent/did/indy/indy_manager.py b/acapy_agent/did/indy/indy_manager.py index c08d82ebe8..c745f51835 100644 --- a/acapy_agent/did/indy/indy_manager.py +++ b/acapy_agent/did/indy/indy_manager.py @@ -37,9 +37,6 @@ async def _get_key_type(self, key_type: str) -> KeyType: def _create_key_pair(self, options: dict, key_type: KeyType) -> Key: seed = options.get("seed") - if seed and not self.profile.settings.get("wallet.allow_insecure_seed"): - raise WalletError("Insecure seed is not allowed") - if seed: seed = validate_seed(seed) return Key.from_secret_bytes(key_type, seed) diff --git a/acapy_agent/did/indy/tests/test_indy_manager.py b/acapy_agent/did/indy/tests/test_indy_manager.py index 5847ea33c4..784df10736 100644 --- a/acapy_agent/did/indy/tests/test_indy_manager.py +++ b/acapy_agent/did/indy/tests/test_indy_manager.py @@ -2,12 +2,10 @@ from aries_askar import AskarError -from acapy_agent.core.in_memory.profile import ( - InMemoryProfile, - InMemoryProfileSession, -) +from acapy_agent.askar.profile import AskarProfileSession from acapy_agent.did.indy.indy_manager import DidIndyManager from acapy_agent.tests import mock +from acapy_agent.utils.testing import create_test_profile from acapy_agent.wallet.did_method import DIDMethods from acapy_agent.wallet.error import WalletError from acapy_agent.wallet.key_type import KeyTypes @@ -15,16 +13,16 @@ class TestIndyManager(IsolatedAsyncioTestCase): async def asyncSetUp(self) -> None: - self.profile = InMemoryProfile.test_profile() + self.profile = await create_test_profile() self.profile.context.injector.bind_instance( - DIDMethods, mock.MagicMock(auto_spec=DIDMethods) + DIDMethods, mock.MagicMock(DIDMethods, auto_spec=True) ) self.profile.context.injector.bind_instance(KeyTypes, KeyTypes()) def test_init(self): assert DidIndyManager(self.profile) - @mock.patch.object(InMemoryProfileSession, "handle") + @mock.patch.object(AskarProfileSession, "handle") async def test_register(self, mock_handle): mock_handle.insert_key = mock.CoroutineMock() mock_handle.insert = mock.CoroutineMock() @@ -42,30 +40,7 @@ async def test_register(self, mock_handle): with self.assertRaises(WalletError): await manager.register({}) - @mock.patch.object(InMemoryProfileSession, "handle") - async def test_register_with_seed_without_allow_insecure(self, mock_handle): - mock_handle.insert_key = mock.CoroutineMock() - mock_handle.insert = mock.CoroutineMock() - manager = DidIndyManager(self.profile) - with self.assertRaises(WalletError): - await manager.register({"seed": "000000000000000000000000Trustee1"}) - - @mock.patch.object(InMemoryProfileSession, "handle") - async def test_register_with_seed_with_allow_insecure(self, mock_handle): - self.profile.context.injector.bind_instance( - DIDMethods, mock.MagicMock(auto_spec=DIDMethods) - ) - self.profile.context.injector.bind_instance(KeyTypes, KeyTypes()) - self.profile.settings.set_value("wallet.allow_insecure_seed", True) - mock_handle.insert_key = mock.CoroutineMock() - mock_handle.insert = mock.CoroutineMock() - manager = DidIndyManager(self.profile) - - result = await manager.register({"seed": "000000000000000000000000Steward1"}) - assert result.get("did") == "did:indy:HPMyRCWfgav5HXtYaaJaZK" - assert result.get("verkey") - - @mock.patch.object(InMemoryProfileSession, "handle") + @mock.patch.object(AskarProfileSession, "handle") async def test_register_with_seed_with_key_type(self, mock_handle): mock_handle.insert_key = mock.CoroutineMock() mock_handle.insert = mock.CoroutineMock() @@ -75,7 +50,7 @@ async def test_register_with_seed_with_key_type(self, mock_handle): assert result.get("did") assert result.get("verkey") - @mock.patch.object(InMemoryProfileSession, "handle") + @mock.patch.object(AskarProfileSession, "handle") async def test_register_with_seed_with_defined_did(self, mock_handle): mock_handle.insert_key = mock.CoroutineMock() mock_handle.insert = mock.CoroutineMock() @@ -85,7 +60,7 @@ async def test_register_with_seed_with_defined_did(self, mock_handle): assert result.get("did") == "did:indy:WRfXPg8dantKVubE3HX8pw" assert result.get("verkey") - @mock.patch.object(InMemoryProfileSession, "handle") + @mock.patch.object(AskarProfileSession, "handle") async def test_register_with_seed_with_all_options(self, mock_handle): self.profile.settings.set_value("wallet.allow_insecure_seed", True) mock_handle.insert_key = mock.CoroutineMock()