示例#1
0
def test_can_build_register_delegation_proof_from_dict_with_missing_proof_type(
        valid_key_name, a_proof, a_controller):
    key = RegisterDelegationProof(name=valid_key_name,
                                  controller=a_controller,
                                  proof=a_proof,
                                  revoked=False)
    as_dict = key.to_dict()
    as_dict.pop('proofType')
    from_dict_key = RegisterDelegationProof.from_dict(as_dict)
    assert from_dict_key.proof_type == DelegationProofType.DID
示例#2
0
def test_build_register_delegation_proof_from_dict_raises_validation_error_if_invalid_proof_type(
        valid_key_name, a_proof, a_controller):
    key = RegisterDelegationProof(name=valid_key_name,
                                  controller=a_controller,
                                  proof=a_proof,
                                  revoked=False)
    as_dict = key.to_dict()
    as_dict['proofType'] = 'invalid'
    with pytest.raises(IdentityValidationError):
        RegisterDelegationProof.from_dict(as_dict)
示例#3
0
def test_can_build_register_delegation_proof_from_dict(valid_key_name, a_proof,
                                                       a_controller,
                                                       proof_type):
    key = RegisterDelegationProof(name=valid_key_name,
                                  controller=a_controller,
                                  proof=a_proof,
                                  revoked=False,
                                  proof_type=proof_type)
    from_dict_key = RegisterDelegationProof.from_dict(key.to_dict())
    assert key == from_dict_key
示例#4
0
def test_can_build_register_delegation_proof(valid_key_name, a_proof,
                                             a_controller, proof_type):
    key = RegisterDelegationProof(name=valid_key_name,
                                  controller=a_controller,
                                  proof=a_proof,
                                  revoked=False,
                                  proof_type=proof_type)
    assert key.name == valid_key_name
    assert key.controller == a_controller
    assert key.proof == a_proof
    assert not key.revoked

    assert key.to_dict() == {
        'id': valid_key_name,
        'controller': str(a_controller),
        'proof': a_proof,
        'proofType': proof_type.value,
        'revoked': False
    }