def test_private_identity_converted_to_delegate() -> None: """Creates private identity and converts it to a delegate.""" identity = PrivateIdentity( CryptoProtocol.SHA256WithRSA.generate_private_key(), "1234567" ) delegate = identity.delegate_of("abcdefgh") assert delegate.identity_id == "1234567" assert isinstance(delegate.public_key, PublicKey) assert delegate.delegator_identity_id == "abcdefgh"
def test_create_identity_add_delegate_content(identity: PrivateIdentity) -> None: """Request content to add a delegate to an identity.""" delegate = identity.delegate_of("abcdefgh") bytes_content, authorisation = identity.sign_entity(delegate) content = json.loads(bytes_content) assert content["_type"] == "AddDelegateRequest" assert content["delegateIdentityId"] == delegate.identity_id assert content["delegatorIdentityId"] == delegate.delegator_identity_id
def test_add_delegate_to_identity( alice: PrivateIdentity, bob: PrivateIdentity, alice_client: Client, ) -> None: """Adds a delegate to an identity.""" delegate = bob.delegate_of(alice.identity_id) content, authorisation = bob.sign_entity(delegate) response = alice_client.put(delegate, content=content, authorisations=[authorisation]) for r in response.resources: # type: ignore[union-attr] if "identities/" in r: assert alice.identity_id in r