예제 #1
0
def test_validate_document_against_resolver_raises_validation_error_if_invalid_delegation(
        valid_doc, other_key_pair, deleg_type):
    wrong_deleg_id = make_identifier(other_key_pair.public_bytes)
    delegated_doc1, inconsistent_deleg_key = get_valid_delegated_doc_and_deleg_proof(
        new_seed(),
        '#issuer1',
        delegating_doc_id=wrong_deleg_id,
        deleg_name='#DelegDoc1')

    builder = RegisterDocumentBuilder()
    if deleg_type == 'auth':
        builder.add_authentication_delegation_obj(inconsistent_deleg_key)
    else:
        builder.add_control_delegation_obj(inconsistent_deleg_key)
    doc_with_invalid_delegation = builder.build_from_existing(valid_doc)
    resolver_client = ResolverClientTest(docs={
        valid_doc.did: valid_doc,
        delegated_doc1.did: delegated_doc1
    })
    with pytest.raises(IdentityInvalidDocumentError) as err_wrapper:
        is_validator_run_success(
            DocumentValidation.validate_document_against_resolver,
            resolver_client, doc_with_invalid_delegation)
    assert isinstance(err_wrapper.value.__cause__, IdentityInvalidProofError)
예제 #2
0
def get_doc_with_keys(public_keys: Iterable[RegisterPublicKey] = None,
                      auth_keys: Iterable[RegisterAuthenticationPublicKey] = None,
                      deleg_control: Iterable[RegisterDelegationProof] = None,
                      deleg_auth: Iterable[RegisterDelegationProof] = None,
                      controller: str = None,
                      did: str = None) -> RegisterDocument:
    builder = RegisterDocumentBuilder()
    _ = [builder.add_public_key_obj(k) for k in (public_keys or ())]
    _ = [builder.add_authentication_key_obj(k) for k in (auth_keys or ())]
    _ = [builder.add_control_delegation_obj(k) for k in (deleg_control or ())]
    _ = [builder.add_authentication_delegation_obj(k) for k in (deleg_auth or ())]

    return builder.build(did=did or 'did:iotics:iotHHHHKpPGWyEC4FFo4d6oyzVVk6MXLmEgY',
                         purpose=DIDType.TWIN,
                         proof='a proof',
                         revoked=True,
                         controller=controller)
 def add_key_to_builder(self, builder: RegisterDocumentBuilder, key: RegisterDelegationProof):  # type: ignore
     builder.add_control_delegation_obj(key)