From 0da83a190de51492e7406800e71c24dd2fd6107f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andra=C5=BE=20Cuderman?= Date: Fri, 18 Feb 2022 10:20:25 +0100 Subject: [PATCH 1/3] fix(IDENT-4193): Move save error state to session context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andraž Cuderman --- .../protocols/present_proof/v2_0/routes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/routes.py b/aries_cloudagent/protocols/present_proof/v2_0/routes.py index ede46b7d4f..8d24d1afe4 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/routes.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/routes.py @@ -1197,13 +1197,13 @@ async def present_proof_problem_report(request: web.BaseRequest): description = body["description"] try: - async with await context.profile.session() as session: + async with context.profile.session() as session: pres_ex_record = await V20PresExRecord.retrieve_by_id(session, pres_ex_id) + await pres_ex_record.save_error_state( + session, + reason=f"created problem report: {description}", + ) report = problem_report_for_record(pres_ex_record, description) - await pres_ex_record.save_error_state( - session, - reason=f"created problem report: {description}", - ) except StorageNotFoundError as err: # other party does not care about meta-problems raise web.HTTPNotFound(reason=err.roll_up) from err except StorageError as err: From 273fc71378f360dcfd856d0f275c99f75020e6ef Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Tue, 22 Feb 2022 10:57:27 +0100 Subject: [PATCH 2/3] feat: query connections by their_public_did Signed-off-by: Timo Glastra --- aries_cloudagent/protocols/connections/v1_0/routes.py | 3 +++ .../protocols/connections/v1_0/tests/test_routes.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/protocols/connections/v1_0/routes.py b/aries_cloudagent/protocols/connections/v1_0/routes.py index ae65d52f99..ac16fa67d3 100644 --- a/aries_cloudagent/protocols/connections/v1_0/routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/routes.py @@ -186,6 +186,8 @@ class ConnectionsListQueryStringSchema(OpenAPISchema): ), ) their_did = fields.Str(description="Their DID", required=False, **INDY_DID) + their_public_did = fields.Str( + description="Their Public DID", required=False, **INDY_DID) their_role = fields.Str( description="Their role in the connection protocol", required=False, @@ -332,6 +334,7 @@ async def connections_list(request: web.BaseRequest): "their_did", "request_id", "invitation_key", + "their_public_did" ): if param_name in request.query and request.query[param_name] != "": tag_filter[param_name] = request.query[param_name] diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py index be40c47e1d..dd5f0d26bb 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py @@ -32,6 +32,7 @@ async def test_connections_list(self): "their_role": ConnRecord.Role.REQUESTER.rfc160, "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, "invitation_key": "some-invitation-key", + "their_public_did": "a_public_did" } STATE_COMPLETED = ConnRecord.State.COMPLETED @@ -89,7 +90,7 @@ async def test_connections_list(self): await test_module.connections_list(self.request) mock_conn_rec.query.assert_called_once_with( ANY, - {"invitation_id": "dummy", "invitation_key": "some-invitation-key"}, + {"invitation_id": "dummy", "invitation_key": "some-invitation-key", "their_public_did": "a_public_did"}, post_filter_positive={ "their_role": [v for v in ConnRecord.Role.REQUESTER.value], "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, From 75e9d0c3023a199cb2ce59df9ef0b9372392b161 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Tue, 22 Feb 2022 11:02:53 +0100 Subject: [PATCH 3/3] style: black formatting Signed-off-by: Timo Glastra --- aries_cloudagent/protocols/connections/v1_0/routes.py | 5 +++-- .../protocols/connections/v1_0/tests/test_routes.py | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/aries_cloudagent/protocols/connections/v1_0/routes.py b/aries_cloudagent/protocols/connections/v1_0/routes.py index ac16fa67d3..b35a6b9067 100644 --- a/aries_cloudagent/protocols/connections/v1_0/routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/routes.py @@ -187,7 +187,8 @@ class ConnectionsListQueryStringSchema(OpenAPISchema): ) their_did = fields.Str(description="Their DID", required=False, **INDY_DID) their_public_did = fields.Str( - description="Their Public DID", required=False, **INDY_DID) + description="Their Public DID", required=False, **INDY_DID + ) their_role = fields.Str( description="Their role in the connection protocol", required=False, @@ -334,7 +335,7 @@ async def connections_list(request: web.BaseRequest): "their_did", "request_id", "invitation_key", - "their_public_did" + "their_public_did", ): if param_name in request.query and request.query[param_name] != "": tag_filter[param_name] = request.query[param_name] diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py index dd5f0d26bb..b769191c25 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py @@ -32,7 +32,7 @@ async def test_connections_list(self): "their_role": ConnRecord.Role.REQUESTER.rfc160, "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, "invitation_key": "some-invitation-key", - "their_public_did": "a_public_did" + "their_public_did": "a_public_did", } STATE_COMPLETED = ConnRecord.State.COMPLETED @@ -90,7 +90,11 @@ async def test_connections_list(self): await test_module.connections_list(self.request) mock_conn_rec.query.assert_called_once_with( ANY, - {"invitation_id": "dummy", "invitation_key": "some-invitation-key", "their_public_did": "a_public_did"}, + { + "invitation_id": "dummy", + "invitation_key": "some-invitation-key", + "their_public_did": "a_public_did", + }, post_filter_positive={ "their_role": [v for v in ConnRecord.Role.REQUESTER.value], "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol,