Skip to content

Commit

Permalink
✅ re-add support for revoking credentials (#559)
Browse files Browse the repository at this point in the history
* 🔥 unused method

* ✨ re-add revocation support

* 🎨

* ✅ test issuer creation of cred def with/without support_revocation

* ✅ re-add test for revoke credential
  • Loading branch information
ff137 authored Nov 28, 2023
1 parent 5b8441b commit 4daa34a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 46 deletions.
3 changes: 1 addition & 2 deletions app/models/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
class CreateCredentialDefinition(BaseModel):
tag: str = Field(..., examples=["default"])
schema_id: str = Field(..., examples=["CXQseFxV34pcb8vf32XhEa:2:test_schema:0.3"])
# support_revocation: bool = Field(default=False)
# TODO: Re-add revocation support
support_revocation: bool = Field(default=False)
revocation_registry_size: int = Field(default=32767)


Expand Down
5 changes: 3 additions & 2 deletions app/routes/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ async def create_credential_definition(
bound_logger = logger.bind(body=credential_definition)
bound_logger.info("POST request received: Create credential definition")

support_revocation = credential_definition.support_revocation

async with client_from_auth(auth) as aries_controller:
# Assert the agent has a public did
bound_logger.debug("Asserting client has public DID")
Expand All @@ -225,7 +227,7 @@ async def create_credential_definition(
result = await aries_controller.credential_definition.publish_cred_def(
body=CredentialDefinitionSendRequest(
schema_id=credential_definition.schema_id,
# support_revocation=credential_definition.support_revocation,
support_revocation=support_revocation,
tag=credential_definition.tag,
)
)
Expand Down Expand Up @@ -287,7 +289,6 @@ async def create_credential_definition(
"Missing both `credential_definition_id` and `transaction_id` from response after publishing cred def."
)

support_revocation = False # TODO: re-add support for revocation
if support_revocation:
# Temporary workaround for "Not issuer of credential definition" error PR #469
time.sleep(1)
Expand Down
38 changes: 0 additions & 38 deletions app/services/acapy_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,44 +165,6 @@ async def accept_taa_if_required(aries_controller: AcaPyClient):
)


async def write_credential_def(
controller: AcaPyClient, schema_id: str, support_revocation: bool = False
) -> str:
"""
Writes Credential Definition to the ledger
Parameters:
----------
controller (AcaPyClient): The aries_cloudcontroller object
schema_id (str): The schema identifier
support_revocation (bool): Whether to support revocation.
Default is False
Returns:
-------
write_cred_response :dict
"""
bound_logger = logger.bind(body={"schema_id": schema_id})
bound_logger.info("Writing credential definition to the ledger")

write_cred_response = await controller.credential_definition.publish_cred_def(
body=CredentialDefinitionSendRequest(
schema_id=schema_id, tag="default", support_revocation=support_revocation
)
)
if not write_cred_response.credential_definition_id:
bound_logger.warning(
"Response from `publish_cred_def` did not contain 'credential_definition_id'."
)
raise CloudApiException(
"Something went wrong. Could not write credential definition to the ledger."
)
bound_logger.info("Successfully published credential definition.")
return write_cred_response.credential_definition_id


async def schema_id_from_credential_definition_id(
controller: AcaPyClient, credential_definition_id: str
):
Expand Down
1 change: 0 additions & 1 deletion app/tests/e2e/issuer/did_sov/test_v1_indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ async def test_send_credential_request(
)


@pytest.mark.skip("Revocation is not supported")
@pytest.mark.anyio
async def test_revoke_credential(
faber_client: RichAsyncClient,
Expand Down
1 change: 0 additions & 1 deletion app/tests/e2e/issuer/did_sov/test_v2_indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ async def test_send_credential_request(
)


@pytest.mark.skip("Revocation is not supported")
@pytest.mark.anyio
async def test_revoke_credential(
faber_client: RichAsyncClient,
Expand Down
17 changes: 16 additions & 1 deletion app/tests/e2e/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,17 @@ async def test_get_credential_definition(


@pytest.mark.anyio
@pytest.mark.parametrize("support_revocation", [False, True])
async def test_create_credential_definition_issuer_tenant(
schema_definition: CredentialSchema,
faber_acapy_client: AcaPyClient,
faber_client: RichAsyncClient,
support_revocation: bool,
):
credential_definition = CreateCredentialDefinition(
schema_id=schema_definition.id,
tag=random_string(5),
support_revocation=False,
support_revocation=support_revocation,
)

auth = acapy_auth_verified(acapy_auth(faber_client.headers["x-api-key"]))
Expand All @@ -147,3 +149,16 @@ async def test_create_credential_definition_issuer_tenant(
f"{faber_public_did.did}:3:CL:{schema.var_schema.seq_no}:{credential_definition.tag}"
)
assert_that(result).has_tag(credential_definition.tag)

if support_revocation:
cred_def_id = result["id"]
# Assert that revocation registry was created
rev_reg_result = (
await faber_acapy_client.revocation.get_active_registry_for_cred_def(
cred_def_id=cred_def_id
)
)
issuer_rev_reg_record = rev_reg_result.result
assert issuer_rev_reg_record
assert cred_def_id == issuer_rev_reg_record.cred_def_id
assert issuer_rev_reg_record.issuer_did == faber_public_did.did
1 change: 0 additions & 1 deletion app/tests/e2e/test_trust_registry_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ async def test_accept_proof_request_verifier_no_public_did(
json={
"tag": random_string(5),
"schema_id": schema_id,
# "support_revocation": True,
},
)

Expand Down

0 comments on commit 4daa34a

Please sign in to comment.