Exemplo n.º 1
0
def test_can_not_send_same_rs_schema(looper, sdk_pool_handle,
                                     sdk_wallet_endorser):
    _, identifier = sdk_wallet_endorser
    authors_did, name, version, type = identifier, "ISO18023_Drivers_License", "1.3", "8"
    _id = identifier + ':' + type + ':' + name + ':' + version
    schema = {'@id': _id, '@type': "0od"}
    request_json = build_rs_schema_request(identifier, schema, name, version)
    sdk_write_rs_schema_and_check(looper, sdk_pool_handle, sdk_wallet_endorser,
                                  request_json)

    with pytest.raises(RequestRejectedException,
                       match=str(AuthConstraintForbidden())):
        request_json = build_rs_schema_request(identifier, schema, name,
                                               version)
        sdk_write_rs_schema_and_check(looper, sdk_pool_handle,
                                      sdk_wallet_endorser, request_json)
Exemplo n.º 2
0
def test_send_rs_schema_one_attrib(looper, sdk_pool_handle,
                                   sdk_wallet_endorser):
    _, identifier = sdk_wallet_endorser
    authors_did, name, version, type = identifier, "ISO18023_Drivers_License", "1.2", "8"
    _id = identifier + ':' + type + ':' + name + ':' + version
    schema = {'@id': _id, '@type': "0od"}
    request_json = build_rs_schema_request(identifier, schema, name, version)
    sdk_write_rs_schema_and_check(looper, sdk_pool_handle, sdk_wallet_endorser,
                                  request_json)
def send_rs_schema_req(looper, sdk_pool_handle, nodeSet, sdk_wallet_trustee):
    _, identifier = sdk_wallet_trustee
    authors_did, name, version, type = identifier, "ISO18023_Drivers_License", "1.1", "8"
    _id = identifier + ':' + type + ':' + name + ':' + version
    schema = TEST_1
    schema['@id'] = _id
    request_json = build_rs_schema_request(identifier, schema, name, version)
    schema_json, reply = sdk_write_rs_schema(looper, sdk_pool_handle, sdk_wallet_trustee, request_json)
    return schema_json, reply
Exemplo n.º 4
0
def test_send_rs_schema_multiple_attrib(looper, sdk_pool_handle,
                                        sdk_wallet_endorser):
    _, identifier = sdk_wallet_endorser
    authors_did, name, version, type = identifier, "ISO18023_Drivers_License", "1.1", "8"
    _id = identifier + ':' + type + ':' + name + ':' + version
    schema = TEST_1
    schema['@id'] = _id
    request_json = build_rs_schema_request(identifier, schema, name, version)
    sdk_write_rs_schema_and_check(looper, sdk_pool_handle, sdk_wallet_endorser,
                                  request_json)
Exemplo n.º 5
0
def test_can_not_send_rs_schema_missing_type(looper, sdk_pool_handle,
                                             sdk_wallet_endorser):
    _, identifier = sdk_wallet_endorser
    authors_did, name, version, type = identifier, "ISO18023_Drivers_License", "1.3", "8"
    _id = identifier + ':' + type + ':' + name + ':' + version
    schema = {'@id': _id}
    request_json = build_rs_schema_request(identifier, schema, name, version)

    with pytest.raises(Exception) as ex_info:
        sdk_write_rs_schema_and_check(looper, sdk_pool_handle,
                                      sdk_wallet_endorser, request_json)
    ex_info.match("validation error")
Exemplo n.º 6
0
def req(request, looper, sdk_pool_handle, sdk_wallet_steward):
    wallet_handle, identifier = sdk_wallet_steward
    if request.param == "ATTRIB":
        raw = json.dumps({'answer': 42})
        request_json = looper.loop.run_until_complete(
            build_attrib_request(identifier,
                                 identifier,
                                 raw=raw,
                                 xhash=None,
                                 enc=None))
    elif request.param == "SCHEMA":
        _, schema_json = looper.loop.run_until_complete(
            issuer_create_schema(identifier, "name", "1.0",
                                 json.dumps(["first", "last"])))
        request_json = looper.loop.run_until_complete(
            build_schema_request(identifier, schema_json))
    elif request.param == "RS_SCHEMA":
        rs_schema = {'@id': "fakeId234e", '@type': "0od"}
        request_json = build_rs_schema_request(identifier, rs_schema,
                                               "ISO18023_Drivers_License",
                                               "1.1")
    elif request.param == "CLAIM_DEF":
        schema_json, _ = sdk_write_schema(looper, sdk_pool_handle,
                                          sdk_wallet_steward)
        schema_id = json.loads(schema_json)['id']

        request = looper.loop.run_until_complete(
            build_get_schema_request(identifier, schema_id))
        reply = sdk_get_reply(
            looper,
            sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_steward,
                                    request))[1]
        _, schema_json = looper.loop.run_until_complete(
            parse_get_schema_response(json.dumps(reply)))

        _, definition_json = looper.loop.run_until_complete(
            issuer_create_and_store_credential_def(
                wallet_handle, identifier, schema_json, "some_tag", "CL",
                json.dumps({"support_revocation": True})))
        request_json = looper.loop.run_until_complete(
            build_cred_def_request(identifier, definition_json))
    elif request.param == "NYM":
        idr, verkey = createHalfKeyIdentifierAndAbbrevVerkey()
        request_json = looper.loop.run_until_complete(
            build_nym_request(identifier, idr, verkey, None, None))

    req_signed = looper.loop.run_until_complete(
        sign_request(wallet_handle, identifier, request_json))
    return Request(**json.loads(req_signed))
def send_rs_schema(looper, sdk_pool_handle, nodeSet, sdk_wallet_trustee):
    _, identifier = sdk_wallet_trustee
    authors_did, name, version, type = identifier, "ISO18023_Drivers_License", "1.1", "8"
    _id = identifier + ':' + type + ':' + name + ':' + version
    schema = {
            '@id': _id,
            '@context': "ctx:sov:2f9F8ZmxuvDqRiqqY29x6dx9oU4qwFTkPbDpWtwGbdUsrCD",
            '@type': "rdfs:Class",
            "rdfs:comment": "ISO18013 International Driver License",
            "rdfs:label": "Driver License",
            "rdfs:subClassOf": {
                "@id": "sch:Thing"
            },
            "driver": "Driver",
            "dateOfIssue": "Date",
            "dateOfExpiry": "Date",
            "issuingAuthority": "Text",
            "licenseNumber": "Text",
            "categoriesOfVehicles": {
                "vehicleType": "Text",
                "vehicleType-input": {
                    "@type": "sch:PropertyValueSpecification",
                    "valuePattern": "^(A|B|C|D|BE|CE|DE|AM|A1|A2|B1|C1|D1|C1E|D1E)$"
                },
                "dateOfIssue": "Date",
                "dateOfExpiry": "Date",
                "restrictions": "Text",
                "restrictions-input": {
                    "@type": "sch:PropertyValueSpecification",
                    "valuePattern": "^([A-Z]|[1-9])$"
                }
            },
            "administrativeNumber": "Text"
        }
    request_json = build_rs_schema_request(identifier, schema, name, version)
    reply = sdk_write_rs_schema(looper, sdk_pool_handle, sdk_wallet_trustee, request_json)
    return reply['result']['txnMetadata']['txnId']