From b8c959877d3905fb7e65639bf35e9e37da40aa2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andra=C5=BE=20Cuderman?= Date: Tue, 18 Jan 2022 16:08:06 +0100 Subject: [PATCH 1/3] Fix version to askar 0.2.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andraž Cuderman --- requirements.askar.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.askar.txt b/requirements.askar.txt index 08d0c2161b..7af2ec91ac 100644 --- a/requirements.askar.txt +++ b/requirements.askar.txt @@ -1,3 +1,3 @@ -aries-askar~=0.2.2 +aries-askar==0.2.2 indy-credx~=0.3 indy-vdr~=0.3.3 From a5e4c7dc9d00673607882b141effdb2a7a9538cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andra=C5=BE=20Cuderman?= Date: Wed, 19 Jan 2022 08:49:46 +0100 Subject: [PATCH 2/3] Update aries askar to patch version 0.2.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andraž Cuderman --- requirements.askar.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.askar.txt b/requirements.askar.txt index 7af2ec91ac..3655606766 100644 --- a/requirements.askar.txt +++ b/requirements.askar.txt @@ -1,3 +1,3 @@ -aries-askar==0.2.2 +aries-askar~=0.2.4 indy-credx~=0.3 indy-vdr~=0.3.3 From d2f4f312866f01d0920436283d11965de27d00f3 Mon Sep 17 00:00:00 2001 From: Andrew Whitehead Date: Wed, 19 Jan 2022 11:14:10 -0800 Subject: [PATCH 3/3] replace blank credential/presentation exchange states with STATE_ABANDONED Signed-off-by: Andrew Whitehead --- .../issue_credential/v1_0/manager.py | 2 +- .../v1_0/models/credential_exchange.py | 6 ++-- .../v1_0/tests/test_manager.py | 2 +- .../issue_credential/v2_0/manager.py | 2 +- .../v2_0/models/cred_ex_record.py | 6 ++-- .../v2_0/tests/test_manager.py | 2 +- .../protocols/present_proof/v1_0/manager.py | 6 ++-- .../v1_0/models/presentation_exchange.py | 6 ++-- .../present_proof/v1_0/tests/test_manager.py | 6 +++- .../v2_0/models/pres_exchange.py | 5 ++-- demo/runners/agent_container.py | 30 +++++++++++++++---- 11 files changed, 52 insertions(+), 21 deletions(-) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py index 27c391222f..d94759ba05 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py @@ -915,7 +915,7 @@ async def receive_problem_report( ) ) - cred_ex_record.state = None + cred_ex_record.state = V10CredentialExchange.STATE_ABANDONED code = message.description.get( "code", ProblemReportReason.ISSUANCE_ABANDONED.value, diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py b/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py index 129cfeb745..e8118bf591 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py @@ -51,6 +51,7 @@ class Meta: STATE_CREDENTIAL_RECEIVED = "credential_received" STATE_ACKED = "credential_acked" STATE_CREDENTIAL_REVOKED = "credential_revoked" + STATE_ABANDONED = "abandoned" def __init__( self, @@ -188,6 +189,7 @@ async def save_error_state( self, session: ProfileSession, *, + state: str = None, reason: str = None, log_params: Mapping[str, Any] = None, log_override: bool = False, @@ -202,10 +204,10 @@ async def save_error_state( override: Override configured logging regimen, print to stderr instead """ - if self._last_state is None: # already done + if self._last_state == state: # already done return - self.state = None + self.state = state or V10CredentialExchange.STATE_ABANDONED if reason: self.error_msg = reason diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py index 5084eebcca..91a34af9ac 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py @@ -1626,7 +1626,7 @@ async def test_receive_problem_report(self): ) save_ex.assert_called_once() - assert ret_exchange.state is None + assert ret_exchange.state == V10CredentialExchange.STATE_ABANDONED async def test_receive_problem_report_x(self): connection_id = "connection-id" diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py index 17d709e19e..a5931011d7 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py @@ -732,7 +732,7 @@ async def receive_problem_report( ) ) - cred_ex_record.state = None + cred_ex_record.state = V20CredExRecord.STATE_ABANDONED code = message.description.get( "code", ProblemReportReason.ISSUANCE_ABANDONED.value, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py index fc23fb5e5a..3ba98c7e98 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py @@ -51,6 +51,7 @@ class Meta: STATE_CREDENTIAL_RECEIVED = "credential-received" STATE_DONE = "done" STATE_CREDENTIAL_REVOKED = "credential-revoked" + STATE_ABANDONED = "abandoned" def __init__( self, @@ -148,6 +149,7 @@ async def save_error_state( self, session: ProfileSession, *, + state: str = None, reason: str = None, log_params: Mapping[str, Any] = None, log_override: bool = False, @@ -162,10 +164,10 @@ async def save_error_state( override: Override configured logging regimen, print to stderr instead """ - if self._last_state is None: # already done + if self._last_state == state: # already done return - self.state = None + self.state = state or V20CredExRecord.STATE_ABANDONED if reason: self.error_msg = reason diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py index 534aa1360e..e941710107 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py @@ -1400,7 +1400,7 @@ async def test_receive_problem_report(self): ) save_ex.assert_called_once() - assert ret_exchange.state is None + assert ret_exchange.state == V20CredExRecord.STATE_ABANDONED async def test_receive_problem_report_x(self): connection_id = "connection-id" diff --git a/aries_cloudagent/protocols/present_proof/v1_0/manager.py b/aries_cloudagent/protocols/present_proof/v1_0/manager.py index 50cf219c41..10354d3d29 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/manager.py @@ -346,7 +346,9 @@ async def receive_presentation( name=name, value=value, ): - presentation_exchange_record.state = None + presentation_exchange_record.state = ( + V10PresentationExchange.STATE_ABANDONED + ) async with self._profile.session() as session: await presentation_exchange_record.save( session, @@ -497,7 +499,7 @@ async def receive_problem_report( ) ) - pres_ex_record.state = None + pres_ex_record.state = V10PresentationExchange.STATE_ABANDONED code = message.description.get("code", ProblemReportReason.ABANDONED.value) pres_ex_record.error_msg = f"{code}: {message.description.get('en', code)}" await pres_ex_record.save(session, reason="received problem report") diff --git a/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py b/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py index ef13ad5b89..bce40f896d 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py @@ -54,6 +54,7 @@ class Meta: STATE_PRESENTATION_RECEIVED = "presentation_received" STATE_VERIFIED = "verified" STATE_PRESENTATION_ACKED = "presentation_acked" + STATE_ABANDONED = "abandoned" def __init__( self, @@ -158,6 +159,7 @@ async def save_error_state( self, session: ProfileSession, *, + state: str = None, reason: str = None, log_params: Mapping[str, Any] = None, log_override: bool = False, @@ -172,10 +174,10 @@ async def save_error_state( override: Override configured logging regimen, print to stderr instead """ - if self._last_state is None: # already done + if self._last_state == state: # already done return - self.state = None + self.state = state or V10PresentationExchange.STATE_ABANDONED if reason: self.error_msg = reason diff --git a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py index 4e0d9d3580..548a97c382 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py @@ -4,6 +4,10 @@ from asynctest import mock as async_mock, TestCase as AsyncTestCase +from aries_cloudagent.protocols.issue_credential.v1_0.models.credential_exchange import ( + V10CredentialExchange, +) + from .....core.in_memory import InMemoryProfile from .....indy.holder import IndyHolder, IndyHolderError from .....indy.issuer import IndyIssuer @@ -1327,7 +1331,7 @@ async def test_receive_problem_report(self): ) save_ex.assert_called_once() - assert ret_exchange.state is None + assert ret_exchange.state == V10CredentialExchange.STATE_ABANDONED async def test_receive_problem_report_x(self): connection_id = "connection-id" diff --git a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py index db98cf0539..298081b848 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py @@ -145,6 +145,7 @@ async def save_error_state( self, session: ProfileSession, *, + state: str = None, reason: str = None, log_params: Mapping[str, Any] = None, log_override: bool = False, @@ -159,10 +160,10 @@ async def save_error_state( override: Override configured logging regimen, print to stderr instead """ - if self._last_state == V20PresExRecord.STATE_ABANDONED: # already done + if self._last_state == state: # already done return - self.state = V20PresExRecord.STATE_ABANDONED + self.state = state or V20PresExRecord.STATE_ABANDONED if reason: self.error_msg = reason diff --git a/demo/runners/agent_container.py b/demo/runners/agent_container.py index 922bcd51d2..33f245e91d 100644 --- a/demo/runners/agent_container.py +++ b/demo/runners/agent_container.py @@ -121,7 +121,7 @@ async def handle_connections(self, message): conn_id = message["connection_id"] # inviter: - if message["state"] == "invitation": + if message.get("state") == "invitation": self.connection_id = conn_id # invitee: @@ -158,7 +158,7 @@ async def handle_connections(self, message): ) async def handle_issue_credential(self, message): - state = message["state"] + state = message.get("state") credential_exchange_id = message["credential_exchange_id"] prev_state = self.cred_state.get(credential_exchange_id) if prev_state == state: @@ -221,8 +221,12 @@ async def handle_issue_credential(self, message): except ClientError: pass + elif state == "abandoned": + log_status("Credential exchange abandoned") + self.log("Problem report message:", message.get("error_msg")) + async def handle_issue_credential_v2_0(self, message): - state = message["state"] + state = message.get("state") cred_ex_id = message["cred_ex_id"] prev_state = self.cred_state.get(cred_ex_id) if prev_state == state: @@ -238,6 +242,7 @@ async def handle_issue_credential_v2_0(self, message): f"/issue-credential-2.0/records/{cred_ex_id}/issue", {"comment": f"Issuing credential, exchange {cred_ex_id}"}, ) + elif state == "offer-received": log_status("#15 After receiving credential offer, send credential request") if message["by_format"]["cred_offer"].get("indy"): @@ -253,10 +258,15 @@ async def handle_issue_credential_v2_0(self, message): await self.admin_POST( f"/issue-credential-2.0/records/{cred_ex_id}/send-request", data ) + elif state == "done": pass # Logic moved to detail record specific handler + elif state == "abandoned": + log_status("Credential exchange abandoned") + self.log("Problem report message:", message.get("error_msg")) + async def handle_issue_credential_v2_0_indy(self, message): rev_reg_id = message.get("rev_reg_id") cred_rev_id = message.get("cred_rev_id") @@ -284,7 +294,7 @@ async def handle_issuer_cred_rev(self, message): pass async def handle_present_proof(self, message): - state = message["state"] + state = message.get("state") presentation_exchange_id = message["presentation_exchange_id"] presentation_request = message["presentation_request"] @@ -366,8 +376,12 @@ async def handle_present_proof(self, message): ) self.log("Proof =", proof["verified"]) + elif state == "abandoned": + log_status("Presentation exchange abandoned") + self.log("Problem report message:", message.get("error_msg")) + async def handle_present_proof_v2_0(self, message): - state = message["state"] + state = message.get("state") pres_ex_id = message["pres_ex_id"] self.log(f"Presentation: state = {state}, pres_ex_id = {pres_ex_id}") @@ -507,11 +521,15 @@ async def handle_present_proof_v2_0(self, message): self.log("Proof =", proof["verified"]) self.last_proof_received = proof + elif state == "abandoned": + log_status("Presentation exchange abandoned") + self.log("Problem report message:", message.get("error_msg")) + async def handle_basicmessages(self, message): self.log("Received message:", message["content"]) async def handle_endorse_transaction(self, message): - self.log("Received transaction message:", message["state"]) + self.log("Received transaction message:", message.get("state")) async def handle_revocation_notification(self, message): self.log("Received revocation notification message:", message)