示例#1
0
def test_claim_def_dynamic_validation_without_ref_to_not_schema(claim_def_request, schema_request,
                                                                claim_def_handler: ClaimDefHandler, creator):
    nym = reqToTxn(Request(identifier=creator, operation={'type': NYM}))
    claim_def_request.operation[REF] = get_seq_no(nym)
    claim_def_handler.ledger.appendTxns([nym])
    with pytest.raises(InvalidClientRequest) as e:
        claim_def_handler.dynamic_validation(claim_def_request)
    assert "Mentioned seqNo ({}) isn't seqNo of the schema.".format(claim_def_request.operation[REF]) \
           in e._excinfo[1].args[0]
示例#2
0
def test_claim_def_dynamic_validation_for_unknown_identifier(
        claim_def_request, schema, claim_def_handler: ClaimDefHandler):
    test_identifier = randomString()
    claim_def_handler.ledger.appendTxns([schema])
    request = Request(identifier=test_identifier,
                      reqId=claim_def_request.reqId,
                      operation=claim_def_request.operation)
    with pytest.raises(
            UnauthorizedClientRequest,
            match='DID {} is not found in the Ledger'.format(test_identifier)):
        claim_def_handler.dynamic_validation(request, 0)
示例#3
0
def test_claim_def_dynamic_validation_for_unknown_identifier(claim_def_request, schema_request,
                                                             claim_def_handler: ClaimDefHandler):
    claim_def_handler.write_request_validator.validate = get_exception(True)
    test_identifier = randomString()
    schema = reqToTxn(schema_request)
    claim_def_request.operation[REF] = get_seq_no(schema)
    claim_def_handler.ledger.appendTxns([schema])
    request = Request(identifier=test_identifier,
                      reqId=claim_def_request.reqId,
                      operation=claim_def_request.operation)
    with pytest.raises(UnauthorizedClientRequest) as e:
        claim_def_handler.dynamic_validation(request)
示例#4
0
def test_claim_def_dynamic_validation_without_permission(
        claim_def_request, schema, claim_def_handler: ClaimDefHandler):
    claim_def_handler.ledger.appendTxns([schema])
    test_identifier = randomString()
    idr = claim_def_handler.database_manager.idr_cache
    add_to_idr(idr, test_identifier, "")

    request = Request(identifier=test_identifier,
                      reqId=claim_def_request.reqId,
                      signature="sig",
                      operation=claim_def_request.operation)
    with pytest.raises(UnauthorizedClientRequest,
                       match="Not enough .* signatures"):
        claim_def_handler.dynamic_validation(request, 0)
示例#5
0
def test_claim_def_dynamic_validation_without_permission(claim_def_request, schema_request,
                                                         claim_def_handler: ClaimDefHandler):
    claim_def_handler.write_request_validator.validate = get_exception(True)
    schema = reqToTxn(schema_request)
    claim_def_request.operation[REF] = get_seq_no(schema)
    claim_def_handler.ledger.appendTxns([schema])

    test_identifier = randomString()
    idr = claim_def_handler.database_manager.idr_cache
    add_to_idr(idr, test_identifier, "")

    request = Request(identifier=test_identifier,
                      reqId=claim_def_request.reqId,
                      operation=claim_def_request.operation)
    with pytest.raises(UnauthorizedClientRequest) as e:
        claim_def_handler.dynamic_validation(request)
示例#6
0
def test_claim_def_dynamic_validation_for_new_claim_def(
        claim_def_request, schema, claim_def_handler: ClaimDefHandler):
    claim_def_handler.ledger.appendTxns([schema])
    claim_def_handler.dynamic_validation(claim_def_request, 0)
示例#7
0
def test_claim_def_dynamic_validation_without_schema(
        claim_def_request, claim_def_handler: ClaimDefHandler):
    with pytest.raises(InvalidClientRequest) as e:
        claim_def_handler.dynamic_validation(claim_def_request, 0)
    assert "Mentioned seqNo ({}) doesn't exist.".format(claim_def_request.operation[REF]) \
           in e._excinfo[1].reason
示例#8
0
def test_claim_def_dynamic_validation_for_new_claim_def(claim_def_request, schema_request,
                                                        claim_def_handler: ClaimDefHandler):
    schema = reqToTxn(schema_request)
    claim_def_request.operation[REF] = get_seq_no(schema)
    claim_def_handler.ledger.appendTxns([schema])
    claim_def_handler.dynamic_validation(claim_def_request)