From 9111a7ecd7344c54fec105c39e6ad0919b5b6773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Humbert?= Date: Fri, 24 Feb 2023 16:43:02 +0100 Subject: [PATCH] feat: allow marking non-SOV DIDs as public MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the restriction for did:sov when marking a DID as public **at the wallet level**. Signed-off-by: Clément Humbert --- aries_cloudagent/wallet/askar.py | 3 --- aries_cloudagent/wallet/in_memory.py | 5 +--- aries_cloudagent/wallet/indy.py | 3 --- .../wallet/tests/test_in_memory_wallet.py | 23 ------------------- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index 2a0093d276..d104d32d36 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -396,9 +396,6 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: info = did item = None - if info.method != SOV: - raise WalletError("Setting public DID is only allowed for did:sov DIDs") - public = await self.get_public_did() if not public or public.did != info.did: storage = AskarStorage(self._session) diff --git a/aries_cloudagent/wallet/in_memory.py b/aries_cloudagent/wallet/in_memory.py index 5023e8d6c0..03fc4fb8aa 100644 --- a/aries_cloudagent/wallet/in_memory.py +++ b/aries_cloudagent/wallet/in_memory.py @@ -17,7 +17,7 @@ ) from .did_info import KeyInfo, DIDInfo from .did_posture import DIDPosture -from .did_method import SOV, DIDMethod, DIDMethods +from .did_method import DIDMethod, DIDMethods from .error import WalletError, WalletDuplicateError, WalletNotFoundError from .key_type import KeyType from .util import b58_to_bytes, bytes_to_b58, random_seed @@ -383,9 +383,6 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: info = did did = info.did - if info.method != SOV: - raise WalletError("Setting public DID is only allowed for did:sov DIDs") - public = await self.get_public_did() if public and public.did == did: info = public diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index 78356946bb..7a99858044 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -687,9 +687,6 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: else: info = did - if info.method != SOV: - raise WalletError("Setting public DID is only allowed for did:sov DIDs") - public = await self.get_public_did() if not public or public.did != info.did: if not info.metadata.get("posted"): diff --git a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py index e9d81ffa27..2558f60914 100644 --- a/aries_cloudagent/wallet/tests/test_in_memory_wallet.py +++ b/aries_cloudagent/wallet/tests/test_in_memory_wallet.py @@ -346,17 +346,6 @@ async def test_create_public_did(self, wallet: InMemoryWallet): info_replace.did, } - @pytest.mark.asyncio - async def test_create_public_did_x_not_sov(self, wallet: InMemoryWallet): - with pytest.raises(WalletError) as context: - await wallet.create_public_did( - KEY, - ED25519, - ) - assert "Setting public DID is only allowed for did:sov DIDs" in str( - context.value - ) - @pytest.mark.asyncio async def test_create_public_did_x_unsupported_key_type_method( self, wallet: InMemoryWallet @@ -400,18 +389,6 @@ async def test_set_public_did(self, wallet: InMemoryWallet): assert info_final.did == info_new.did assert info_final.metadata.get("posted") - @pytest.mark.asyncio - async def test_set_public_did_x_not_sov(self, wallet: InMemoryWallet): - info = await wallet.create_local_did( - KEY, - ED25519, - ) - with pytest.raises(WalletError) as context: - await wallet.set_public_did(info.did) - assert "Setting public DID is only allowed for did:sov DIDs" in str( - context.value - ) - @pytest.mark.asyncio async def test_sign_verify(self, wallet: InMemoryWallet): info = await wallet.create_local_did(