Esempio n. 1
0
def step_impl(context, agent_name, schema_name):
    agent = context.active_agents[agent_name]

    schema_info = read_schema_data(schema_name)

    schemas = agent_container_GET(agent["agent"], "/schemas/created")
    assert len(schemas["schema_ids"]) == 1

    schema_id = schemas["schema_ids"][0]
    schema = agent_container_GET(agent["agent"], "/schemas/" + schema_id)
Esempio n. 2
0
def step_impl(context, agent_name, schema_name):
    agent = context.active_agents[agent_name]

    schema_info = read_schema_data(schema_name)

    cred_defs = agent_container_GET(agent["agent"],
                                    "/credential-definitions/created")
    assert len(cred_defs["credential_definition_ids"]) == 1

    cred_def_id = cred_defs["credential_definition_ids"][0]
    cred_def = agent_container_GET(agent["agent"],
                                   "/credential-definitions/" + cred_def_id)

    context.cred_def_id = cred_def_id
Esempio n. 3
0
def step_impl(context, agent_name, schema_name):
    agent = context.active_agents[agent_name]

    connection_id = agent["agent"].agent.connection_id

    # TODO for now assume there is a single schema; should find the schema based on the supplied name
    schemas = agent_container_GET(agent["agent"], "/schemas/created")
    assert len(schemas["schema_ids"]) == 1

    schema_id = schemas["schema_ids"][0]
    created_txn = agent_container_POST(
        agent["agent"],
        "/credential-definitions",
        data={
            "schema_id": schema_id,
            "tag": "test_cred_def_with_endorsement",
            "support_revocation": True,
            "revocation_registry_size": 1000,
        },
        params={
            "conn_id": connection_id,
            "create_transaction_for_endorser": "true"
        },
    )

    # assert goodness
    if agent["agent"].endorser_role and agent[
            "agent"].endorser_role == "author":
        assert created_txn["txn"]["state"] == "request_sent"
    else:
        assert created_txn["txn"]["state"] == "transaction_created"
    if not "txn_ids" in context:
        context.txn_ids = {}
    context.txn_ids["AUTHOR"] = created_txn["txn"]["transaction_id"]
def step_impl(context, holder):
    agent = context.active_agents[holder]

    # get the required revocation info from the last credential exchange
    cred_exchange = context.cred_exchange

    cred_exchange = agent_container_GET(
        agent["agent"],
        "/issue-credential-2.0/records/" + cred_exchange["cred_ex_id"])
    context.cred_exchange = cred_exchange
    print("rev_reg_id:", cred_exchange["indy"]["rev_reg_id"])
    print("cred_rev_id:", cred_exchange["indy"]["cred_rev_id"])
    print("connection_id:", cred_exchange["cred_ex_record"]["connection_id"])

    # revoke the credential
    revoke_status = agent_container_POST(
        agent["agent"],
        "/revocation/revoke",
        data={
            "rev_reg_id": cred_exchange["indy"]["rev_reg_id"],
            "cred_rev_id": cred_exchange["indy"]["cred_rev_id"],
            "publish": "Y",
            "connection_id": cred_exchange["cred_ex_record"]["connection_id"],
        },
    )

    # pause for a few seconds
    async_sleep(3.0)
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]

    # get the required revocation info from the last credential exchange
    cred_exchange = context.cred_exchange

    cred_exchange = agent_container_GET(
        agent["agent"], "/issue-credential-2.0/records/" + cred_exchange["cred_ex_id"]
    )
    context.cred_exchange = cred_exchange

    # revoke the credential
    agent_container_POST(
        agent["agent"],
        "/revocation/revoke",
        data={
            "rev_reg_id": cred_exchange["indy"]["rev_reg_id"],
            "cred_rev_id": cred_exchange["indy"]["cred_rev_id"],
            "publish": False,
            "connection_id": cred_exchange["cred_ex_record"]["connection_id"],
        },
    )

    # pause for a few seconds
    async_sleep(3.0)
Esempio n. 6
0
def step_impl(context, agent_name, schema_name):
    agent = context.active_agents[agent_name]

    schema_info = read_schema_data(schema_name)

    schemas = {"schema_ids": []}
    i = 5
    while 0 == len(schemas["schema_ids"]) and i > 0:
        async_sleep(1.0)
        schemas = agent_container_GET(agent["agent"], "/schemas/created")
        i = i - 1
    assert len(schemas["schema_ids"]) == 1

    schema_id = schemas["schema_ids"][0]
    schema = agent_container_GET(agent["agent"], "/schemas/" + schema_id)

    context.schema_name = schema_name
Esempio n. 7
0
def step_impl(context, agent_name, schema_name):
    agent = context.active_agents[agent_name]

    schema_info = read_schema_data(schema_name)

    cred_defs = {"credential_definition_ids": []}
    i = 5
    while 0 == len(cred_defs["credential_definition_ids"]) and i > 0:
        async_sleep(1.0)
        cred_defs = agent_container_GET(agent["agent"],
                                        "/credential-definitions/created")
        i = i - 1
    assert len(cred_defs["credential_definition_ids"]) == 1

    cred_def_id = cred_defs["credential_definition_ids"][0]
    cred_def = agent_container_GET(agent["agent"],
                                   "/credential-definitions/" + cred_def_id)

    context.cred_def_id = cred_def_id
Esempio n. 8
0
def step_impl(context, holder_name, issuer_name):
    agent = context.active_agents[holder_name]

    # fetch the credential - there only is one in the wallet
    cred_list = agent_container_GET(
        agent["agent"],
        "/credentials",
        params={},
    )
    assert len(cred_list["results"]) == 1
    cred_id = cred_list["results"][0]["referent"]

    # check revocation status for the credential
    revocation_status = agent_container_GET(
        agent["agent"],
        f"/credential/revoked/{cred_id}",
        params={"to": int(time.time())},
    )
    assert revocation_status["revoked"] == True
Esempio n. 9
0
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]

    async_sleep(1.0)
    txns = agent_container_GET(agent["agent"], "/transactions")
    requested_txn = txns["results"][0]
    assert requested_txn["state"] == "transaction_endorsed"
    txn_id = requested_txn["_id"]

    written_txn = agent_container_POST(agent["agent"],
                                       "/transactions/" + txn_id + "/write")

    assert written_txn["state"] == "transaction_completed"
Esempio n. 10
0
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]
    txn_id = context.txn_ids["AUTHOR"]

    async_sleep(1.0)
    txn = agent_container_GET(agent["agent"], "/transactions/" + txn_id)
    requested_txn = txn
    assert requested_txn["state"] == "transaction_endorsed"

    written_txn = agent_container_POST(agent["agent"],
                                       "/transactions/" + txn_id + "/write")

    assert written_txn["state"] == "transaction_acked"
Esempio n. 11
0
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]

    rev_regs = agent_container_GET(
        agent["agent"],
        "/revocation/registries/created",
        params={
            "cred_def_id": context.cred_def_id,
        },
    )
    assert len(rev_regs["rev_reg_ids"]) == 1

    rev_reg_id = rev_regs["rev_reg_ids"][0]

    context.rev_reg_id = rev_reg_id
Esempio n. 12
0
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]

    txns = {"results": []}
    i = 5
    while 0 == len(txns["results"]) and i > 0:
        async_sleep(1.0)
        txns = agent_container_GET(agent["agent"], "/transactions")
        i = i - 1
    requested_txn = txns["results"][0]
    assert requested_txn["state"] == "request_received"
    txn_id = requested_txn["_id"]

    endorsed_txn = agent_container_POST(agent["agent"],
                                        "/transactions/" + txn_id + "/endorse")

    assert endorsed_txn["state"] == "transaction_endorsed"
def step_impl(context, issuer, schema_name):
    agent = context.active_agents[issuer]

    schema_info = read_schema_data(schema_name)
    cred_def_id = aries_container_create_schema_cred_def(
        agent["agent"],
        schema_info["schema"]["schema_name"],
        schema_info["schema"]["attributes"],
        version=schema_info["schema"]["schema_version"],
    )

    # confirm the cred def was actually created
    async_sleep(2.0)
    cred_def_saved = agent_container_GET(
        agent["agent"], "/credential-definitions/" + cred_def_id)
    assert cred_def_saved

    context.schema_name = schema_name
    context.cred_def_id = cred_def_id
Esempio n. 14
0
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]

    rev_regs = {"rev_reg_ids": []}
    i = 5
    while 0 == len(rev_regs["rev_reg_ids"]) and i > 0:
        async_sleep(1.0)
        rev_regs = agent_container_GET(
            agent["agent"],
            "/revocation/registries/created",
            params={
                "cred_def_id": context.cred_def_id,
            },
        )
        i = i - 1
    assert len(rev_regs["rev_reg_ids"]) == 1

    rev_reg_id = rev_regs["rev_reg_ids"][0]

    context.rev_reg_id = rev_reg_id
Esempio n. 15
0
def step_impl(context, agent_name):
    agent = context.active_agents[agent_name]

    # find the transaction with state "request_received"
    txns = {"results": []}
    i = 5
    while 0 == len(txns["results"]) and i > 0:
        async_sleep(1.0)
        txns_queued = agent_container_GET(agent["agent"], "/transactions")
        for j in range(len(txns_queued["results"])):
            if txns_queued["results"][j]["state"] == "request_received":
                txns["results"].append(txns_queued["results"][j])
        i = i - 1
    requested_txn = txns["results"][0]
    assert requested_txn["state"] == "request_received"
    txn_id = requested_txn["transaction_id"]

    endorsed_txn = agent_container_POST(agent["agent"],
                                        "/transactions/" + txn_id + "/endorse")

    assert endorsed_txn["state"] == "transaction_endorsed"