Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use invitation key for connection query #1570

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 12 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, I learned a new trick

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,15 @@ 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