Skip to content

Commit

Permalink
Merge pull request #1570 from hyperledger/fix/connection-invitation-key
Browse files Browse the repository at this point in the history
fix: use invitation key for connection query
  • Loading branch information
andrewwhitehead authored Dec 21, 2021
2 parents 953fd32 + 8c1470e commit cd5588f
Show file tree
Hide file tree
Showing 2 changed files with 13 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
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
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

0 comments on commit cd5588f

Please sign in to comment.