Skip to content

Commit

Permalink
Added an integration test for the autoated endorsement scenario
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Costanzo <[email protected]>
  • Loading branch information
ianco committed Sep 29, 2021
1 parent 29f90b9 commit d0cb97a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 13 deletions.
29 changes: 28 additions & 1 deletion demo/features/0586-sign-transaction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions


@T002-RFC0586
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential, manually invoking each endorsement endpoint
Given we have "2" agents
| name | role | capabilities |
| Acme | endorser | <Acme_capabilities> |
Expand Down Expand Up @@ -96,3 +96,30 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
# | --revocation --public-did --mediation | --revocation --mediation | driverslicense | Data_DL_NormalizedValues |
# | --revocation --public-did --multitenant | --revocation --multitenant | driverslicense | Data_DL_NormalizedValues |
# | --revocation --public-did --mediation --multitenant | --revocation --mediation --multitenant | driverslicense | Data_DL_NormalizedValues |

@T003-RFC0586
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential, with auto endorsing workflow
Given we have "2" agents
| name | role | capabilities |
| Acme | endorser | <Acme_capabilities> |
| Bob | author | <Bob_capabilities> |
And "Acme" and "Bob" have an existing connection
When "Acme" has a DID with role "ENDORSER"
And "Bob" has a DID with role "AUTHOR"
And "Acme" connection has job role "TRANSACTION_ENDORSER"
And "Bob" connection has job role "TRANSACTION_AUTHOR"
And "Bob" connection sets endorser info
And "Bob" authors a schema transaction with <Schema_name>
And "Bob" has written the schema <Schema_name> to the ledger
And "Bob" authors a credential definition transaction with <Schema_name>
And "Bob" has written the credential definition for <Schema_name> to the ledger
And "Bob" has written the revocation registry definition to the ledger
And "Bob" has written the revocation registry entry transaction to the ledger
And "Acme" has an issued <Schema_name> credential <Credential_data> from "Bob"
And "Bob" revokes the credential without publishing the entry
And "Bob" authors a revocation registry entry publishing transaction
Then "Acme" can verify the credential from "Bob" was revoked

Examples:
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
| --endorser-role endorser --revocation --public-did | --endorser-role author --revocation | driverslicense | Data_DL_NormalizedValues |
68 changes: 56 additions & 12 deletions demo/features/steps/0586-sign-transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def step_impl(context, agent_name, schema_name):
)

# assert goodness
assert created_txn["txn"]["state"] == "transaction_created"
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"]
Expand Down Expand Up @@ -175,7 +179,12 @@ def step_impl(context, agent_name, schema_name):

schema_info = read_schema_data(schema_name)

schemas = agent_container_GET(agent["agent"], "/schemas/created")
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]
Expand Down Expand Up @@ -211,7 +220,10 @@ def step_impl(context, agent_name, schema_name):
)

# assert goodness
assert created_txn["txn"]["state"] == "transaction_created"
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"]
Expand All @@ -228,7 +240,14 @@ def step_impl(context, agent_name, schema_name):

schema_info = read_schema_data(schema_name)

cred_defs = agent_container_GET(agent["agent"], "/credential-definitions/created")
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]
Expand Down Expand Up @@ -293,13 +312,18 @@ def step_impl(context, agent_name, schema_name):
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,
},
)
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]
Expand Down Expand Up @@ -333,6 +357,19 @@ def step_impl(context, agent_name):
)


@when(
'"{agent_name}" has written the revocation registry entry transaction to the ledger'
)
@then(
'"{agent_name}" has written the revocation registry entry transaction to the ledger'
)
def step_impl(context, agent_name):
agent = context.active_agents[agent_name]

# TODO not sure what to check here, let's just do a short pause
async_sleep(2.0)


@when(
'"{agent_name}" authors a revocation registry entry transaction for the credential definition matching {schema_name}'
)
Expand Down Expand Up @@ -430,7 +467,11 @@ def step_impl(context, agent_name):
"create_transaction_for_endorser": "true",
},
)
assert created_txn["txn"]["state"] == "transaction_created"

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"]
Expand All @@ -440,6 +481,9 @@ def step_impl(context, agent_name):
def step_impl(context, holder_name, issuer_name):
agent = context.active_agents[holder_name]

# sleep here to allow the auto-endorser process to complete
async_sleep(2.0)

# fetch the credential - there only is one in the wallet
cred_list = agent_container_GET(
agent["agent"],
Expand Down

0 comments on commit d0cb97a

Please sign in to comment.