diff --git a/aries-test-harness/agent_test_utils.py b/aries-test-harness/agent_test_utils.py index f69e4515..7e375dfb 100644 --- a/aries-test-harness/agent_test_utils.py +++ b/aries-test-harness/agent_test_utils.py @@ -56,10 +56,10 @@ def get_relative_timestamp_to_epoch(timestamp): def format_cred_proposal_by_aip_version( - context, aip_version, cred_data, connection_id: Optional[str] = None, filters=None + context, aip_version, cred_data, connection_id: Optional[str] = None, filters=None, did_for_id=None ): if aip_version == "AIP20": - filters = amend_filters_with_runtime_data(context, filters) + filters = amend_filters_with_runtime_data(context, filters, did_for_id) credential_proposal = { "credential_preview": { "@type": "issue-credential/2.0/credential-preview", @@ -80,7 +80,7 @@ def get_schema_name(context): return context.schema["schema_name"] -def amend_filters_with_runtime_data(context, filters): +def amend_filters_with_runtime_data(context, filters, did_for_id=None): schema_name = get_schema_name(context) # This method will need comdification as new types of filters are used. Intially "indy" is used. if "indy" in filters: @@ -131,6 +131,9 @@ def amend_filters_with_runtime_data(context, filters): + "Z" ) credential["issuanceDate"] = created_datetime + # Check if "credentialSubject" is in json_ld and then check if "id" is not already in "credentialSubject" + if did_for_id and "credentialSubject" in json_ld["credential"] and "id" not in json_ld["credential"]["credentialSubject"]: + json_ld["credential"]["credentialSubject"]["id"] = did_for_id return filters diff --git a/aries-test-harness/features/steps/0037-present-proof.py b/aries-test-harness/features/steps/0037-present-proof.py index 6bbe2986..b3c777bf 100644 --- a/aries-test-harness/features/steps/0037-present-proof.py +++ b/aries-test-harness/features/steps/0037-present-proof.py @@ -354,10 +354,8 @@ def step_impl(context, verifier): resp_json = json.loads(resp_text) assert resp_json["state"] == "done" - # FIXME: why do we only store the verified property if support_revocation is enabled? - if context.support_revocation: - verified = resp_json["verified"] == True or resp_json["verified"] == "true" - context.credential_verification_dict[context.presentation_thread_id] = verified + verified = resp_json["verified"] == True or resp_json["verified"] == "true" + context.credential_verification_dict[context.presentation_thread_id] = verified @then('"{prover}" has the proof verified') diff --git a/aries-test-harness/features/steps/0453-issue-credential-v2.py b/aries-test-harness/features/steps/0453-issue-credential-v2.py index fb61e84e..2697e933 100644 --- a/aries-test-harness/features/steps/0453-issue-credential-v2.py +++ b/aries-test-harness/features/steps/0453-issue-credential-v2.py @@ -88,6 +88,12 @@ def step_impl(context, holder, cred_format, issuer, credential_data): ), f"credential data has no filter for cred format {cred_format}" filters = {cred_format: context.filters[cred_format]} + # It the credential format is json-ls then get a holder did for the credentialSubject.id by calling the prepare-json-ld command. + if cred_format == CRED_FORMAT_JSON_LD: + holder_did_for_id = create_did_for_id(context, holder, cred_format) + else: + holder_did_for_id = None + # This call may need to be formated by cred_format instead of version. Reassess when more types are used. credential_offer = format_cred_proposal_by_aip_version( context, @@ -95,6 +101,7 @@ def step_impl(context, holder, cred_format, issuer, credential_data): context.credential_data, context.connection_id_dict[holder][issuer], filters, + holder_did_for_id, ) (resp_status, resp_text) = agent_backchannel_POST( @@ -110,6 +117,28 @@ def step_impl(context, holder, cred_format, issuer, credential_data): context.cred_thread_id = resp_json["thread_id"] +def create_did_for_id(context, agent: str, cred_format: str = CRED_FORMAT_INDY): + if cred_format == CRED_FORMAT_JSON_LD: + agent_url = context.config.userdata.get(agent) + + data = {"did_method": context.did_method, "proof_type": context.proof_type} + + (resp_status, resp_text) = agent_backchannel_POST( + agent_url + "/agent/command/", + "issue-credential-v2", + operation="prepare-json-ld", + data=data, + ) + + assert ( + resp_status == 200 + ), f"issue-credential-v2/prepare-json-ld: resp_status {resp_status} is not 200; {resp_text}" + resp_json = json.loads(resp_text) + + return resp_json["did"] + else: + raise Exception(f"Unknown credential format {cred_format}") + @given('"{issuer}" offers the "{cred_format}" credential') @when('"{issuer}" offers the "{cred_format}" credential') def step_impl(context, issuer, cred_format): diff --git a/aries-test-harness/features/steps/0454-present-proof-v2-v3.py b/aries-test-harness/features/steps/0454-present-proof-v2-v3.py index 65de6a3b..ed6870d3 100644 --- a/aries-test-harness/features/steps/0454-present-proof-v2-v3.py +++ b/aries-test-harness/features/steps/0454-present-proof-v2-v3.py @@ -379,11 +379,10 @@ def step_impl(context, verifier): resp_json = json.loads(resp_text) assert resp_json["state"] == "done" - if context.support_revocation: - # Add the verified property returned to the credential verification dictionary to check in subsequent steps. Key by presentation thread id - context.credential_verification_dict[ - context.presentation_thread_id - ] = strtobool(resp_json["verified"]) + # Add the verified property returned to the credential verification dictionary to check in subsequent steps. Key by presentation thread id + context.credential_verification_dict[ + context.presentation_thread_id + ] = strtobool(resp_json["verified"]) @then('"{prover}" has the proof with formats verified')