From a6ec8d283e4349b185be7e846e22d2fc77c87c8d Mon Sep 17 00:00:00 2001 From: sklump Date: Thu, 20 Aug 2020 19:21:09 +0000 Subject: [PATCH] indy-libvcx sets non_revoked to None: accommodate Signed-off-by: sklump --- .../protocols/present_proof/v1_0/manager.py | 2 +- .../present_proof/v1_0/tests/test_manager.py | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/manager.py b/aries_cloudagent/protocols/present_proof/v1_0/manager.py index e65b69effc..a4741ccf7a 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/manager.py @@ -330,7 +330,7 @@ async def create_presentation( non_revoc_interval = {"from": 0, "to": epoch_now} non_revoc_interval.update( - presentation_exchange_record.presentation_request.get("non_revoked", {}) + presentation_exchange_record.presentation_request.get("non_revoked") or {} ) revoc_reg_deltas = {} diff --git a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py index 6bccdb98b6..46a4c153e9 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_manager.py @@ -332,6 +332,56 @@ async def test_create_presentation(self): save_ex.assert_called_once() assert exchange_out.state == V10PresentationExchange.STATE_PRESENTATION_SENT + async def test_create_presentation_proof_req_non_revoc_interval_none(self): + self.context.connection_record = async_mock.MagicMock() + self.context.connection_record.connection_id = CONN_ID + + exchange_in = V10PresentationExchange() + indy_proof_req = await PRES_PREVIEW.indy_proof_request( + name=PROOF_REQ_NAME, + version=PROOF_REQ_VERSION, + nonce=PROOF_REQ_NONCE, + ledger=await self.context.inject(BaseLedger, required=False), + ) + indy_proof_req["non_revoked"] = None # simulate interop with indy-vcx + + exchange_in.presentation_request = indy_proof_req + request = async_mock.MagicMock() + request.indy_proof_request = async_mock.MagicMock() + request._thread_id = "dummy" + self.context.message = request + + more_magic_rr = async_mock.MagicMock( + get_or_fetch_local_tails_path=async_mock.CoroutineMock( + return_value="/tmp/sample/tails/path" + ) + ) + with async_mock.patch.object( + V10PresentationExchange, "save", autospec=True + ) as save_ex, async_mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, async_mock.patch.object( + test_module, "RevocationRegistry", autospec=True + ) as mock_rr: + mock_rr.from_definition = async_mock.MagicMock(return_value=more_magic_rr) + + mock_attach_decorator.from_indy_dict = async_mock.MagicMock( + return_value=mock_attach_decorator + ) + + req_creds = await indy_proof_req_preview2indy_requested_creds( + indy_proof_req, holder=self.holder + ) + assert not req_creds["self_attested_attributes"] + assert len(req_creds["requested_attributes"]) == 2 + assert len(req_creds["requested_predicates"]) == 1 + + (exchange_out, pres_msg) = await self.manager.create_presentation( + exchange_in, req_creds + ) + save_ex.assert_called_once() + assert exchange_out.state == V10PresentationExchange.STATE_PRESENTATION_SENT + async def test_create_presentation_self_asserted(self): self.context.connection_record = async_mock.MagicMock() self.context.connection_record.connection_id = CONN_ID