From aee9c21d402bc3feb7c22ea19ac6fc0da5072385 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Tue, 21 Dec 2021 17:29:32 +0100 Subject: [PATCH 1/2] fix: use invitation key for connection query Signed-off-by: Timo Glastra --- .../protocols/connections/v1_0/routes.py | 1 + .../connections/v1_0/tests/test_routes.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/protocols/connections/v1_0/routes.py b/aries_cloudagent/protocols/connections/v1_0/routes.py index a7c7103c99..3e05d60a78 100644 --- a/aries_cloudagent/protocols/connections/v1_0/routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/routes.py @@ -331,6 +331,7 @@ async def connections_list(request: web.BaseRequest): "my_did", "their_did", "request_id", + "invitation_key" ): 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 1cbfa48c9d..23ce3ba1ae 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py @@ -1,5 +1,6 @@ import json +from unittest.mock import ANY from asynctest import TestCase as AsyncTestCase from asynctest import mock as async_mock @@ -30,6 +31,7 @@ async def test_connections_list(self): "invitation_id": "dummy", # exercise tag filter assignment "their_role": ConnRecord.Role.REQUESTER.rfc160, "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, + "invitation_key": "some-invitation-key" } STATE_COMPLETED = ConnRecord.State.COMPLETED @@ -40,7 +42,7 @@ async def test_connections_list(self): test_module, "ConnRecord", autospec=True ) as mock_conn_rec: mock_conn_rec.query = async_mock.CoroutineMock() - mock_conn_rec.Role = async_mock.MagicMock(return_value=ROLE_REQUESTER) + mock_conn_rec.Role = ConnRecord.Role mock_conn_rec.State = async_mock.MagicMock( COMPLETED=STATE_COMPLETED, INVITATION=STATE_INVITATION, @@ -85,6 +87,18 @@ async def test_connections_list(self): test_module.web, "json_response" ) as mock_response: await test_module.connections_list(self.request) + mock_conn_rec.query.assert_called_once_with( + ANY, + { + "invitation_id": "dummy", + "invitation_key": "some-invitation-key" + }, + post_filter_positive={ + "their_role": [v for v in ConnRecord.Role.REQUESTER.value], + "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, + }, + alt=True + ) mock_response.assert_called_once_with( { "results": [ From f7ab1e05cf59a266c4d35dbf9286b73d2605dd78 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Tue, 21 Dec 2021 17:32:37 +0100 Subject: [PATCH 2/2] style: black formatting Signed-off-by: Timo Glastra --- aries_cloudagent/protocols/connections/v1_0/routes.py | 2 +- .../protocols/connections/v1_0/tests/test_routes.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/aries_cloudagent/protocols/connections/v1_0/routes.py b/aries_cloudagent/protocols/connections/v1_0/routes.py index 3e05d60a78..ae65d52f99 100644 --- a/aries_cloudagent/protocols/connections/v1_0/routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/routes.py @@ -331,7 +331,7 @@ async def connections_list(request: web.BaseRequest): "my_did", "their_did", "request_id", - "invitation_key" + "invitation_key", ): 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 23ce3ba1ae..be40c47e1d 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py @@ -31,7 +31,7 @@ async def test_connections_list(self): "invitation_id": "dummy", # exercise tag filter assignment "their_role": ConnRecord.Role.REQUESTER.rfc160, "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, - "invitation_key": "some-invitation-key" + "invitation_key": "some-invitation-key", } STATE_COMPLETED = ConnRecord.State.COMPLETED @@ -89,15 +89,12 @@ 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"}, post_filter_positive={ "their_role": [v for v in ConnRecord.Role.REQUESTER.value], "connection_protocol": ConnRecord.Protocol.RFC_0160.aries_protocol, }, - alt=True + alt=True, ) mock_response.assert_called_once_with( {