Skip to content

Commit

Permalink
fix: use invitation key for connection query
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed Dec 21, 2021
1 parent be0f462 commit aee9c21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions aries_cloudagent/protocols/connections/v1_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 15 additions & 1 deletion aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json

from unittest.mock import ANY
from asynctest import TestCase as AsyncTestCase
from asynctest import mock as async_mock

Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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": [
Expand Down

0 comments on commit aee9c21

Please sign in to comment.