def test_can_get_generic_delegation_proof(other_key_pair_secrets): subject_doc = get_valid_document_from_secret(other_key_pair_secrets, '#DelegatedDoc') subject_issuer, proof = AdvancedIdentityLocalApi. \ create_generic_delegation_proof(subject_doc=subject_doc, subject_secrets=other_key_pair_secrets) assert subject_issuer.did == subject_doc.did assert proof.content == b'' assert proof.p_type == DelegationProofType.GENERIC
def test_can_get_delegation_proof(base_doc_issuer, other_key_pair_secrets): subject_doc = get_valid_document_from_secret(other_key_pair_secrets, '#DelegatedDoc') subject_issuer, proof = AdvancedIdentityLocalApi. \ create_delegation_proof(delegating_issuer=base_doc_issuer, subject_doc=subject_doc, subject_secrets=other_key_pair_secrets) assert subject_issuer.did == subject_doc.did assert proof.content == base_doc_issuer.did.encode() assert proof.p_type == DelegationProofType.DID
def doc_delegating_authentication(delegating_issuer_name, delegating_secrets, allowed_issuer_secrets, allowed_issuer): doc = get_valid_document_from_secret(delegating_secrets, delegating_issuer_name) delegating_issuer = Issuer.build(doc.did, delegating_issuer_name) proof = Proof.build(allowed_issuer_secrets, allowed_issuer, content=delegating_issuer.did.encode()) return RegisterDocumentBuilder() \ .add_authentication_delegation_obj(RegisterDelegationProof.build('#ADeleg', controller=allowed_issuer, proof=proof.signature)) \ .build_from_existing(doc)
def test_can_create_new_registered_identity_will_not_override_doc_if_exists( valid_key_pair_secrets, valid_key_pair): existing_doc_did = make_identifier(valid_key_pair.public_bytes) resolver_client = ResolverClientTest( docs={ existing_doc_did: get_valid_document_from_secret(valid_key_pair_secrets, '#ExistingDoc') }) api = AdvancedIdentityRegisterApi(resolver_client) registered_id = api.new_registered_identity(DIDType.AGENT, valid_key_pair_secrets, name='#NewDoc') assert registered_id.issuer.name == '#ExistingDoc' registered_doc = resolver_client.get_document(registered_id.issuer.did) assert registered_doc assert registered_doc.public_keys.get('#ExistingDoc') assert '#NewDoc' not in registered_doc.public_keys
def test_can_delegate_control(base_doc, valid_key_pair_secrets, other_key_pair_secrets): subject_doc = get_valid_document_from_secret(other_key_pair_secrets, '#DelegatedDoc') resolver_client = ResolverClientTest(docs={ base_doc.did: base_doc, subject_doc.did: subject_doc }) api = AdvancedIdentityRegisterApi(resolver_client) assert not resolver_client.docs[base_doc.did].control_delegation_proof api.delegate_control(delegating_secrets=valid_key_pair_secrets, delegating_did=base_doc.did, subject_secrets=other_key_pair_secrets, subject_did=subject_doc.did, delegation_name='#NewControlDeleg') control_deleg = resolver_client.docs[ base_doc.did].control_delegation_proof.get('#NewControlDeleg') assert control_deleg assert control_deleg.name == '#NewControlDeleg' assert not control_deleg.revoked assert control_deleg.proof assert control_deleg.controller == Issuer.build(subject_doc.did, '#DelegatedDoc')
def base_doc(valid_key_pair_secrets, base_doc_issuer_name): return get_valid_document_from_secret(valid_key_pair_secrets, base_doc_issuer_name)
def valid_doc(valid_issuer, valid_key_pair_secrets): return get_valid_document_from_secret(valid_key_pair_secrets, valid_issuer.name)
def allowed_issuer_doc(allowed_issuer_name, allowed_issuer_secrets): return get_valid_document_from_secret(allowed_issuer_secrets, allowed_issuer_name)
def authentication_subject_doc(other_key_pair_secrets, valid_key_pair, allowed_issuer_name): return RegisterDocumentBuilder() \ .add_public_key_obj(RegisterPublicKey(allowed_issuer_name, valid_key_pair.public_base58, revoked=False)) \ .build_from_existing(get_valid_document_from_secret(other_key_pair_secrets, '#Adoc'))