diff --git a/aries_cloudagent/protocols/present_proof/v1_0/routes.py b/aries_cloudagent/protocols/present_proof/v1_0/routes.py index cd1b68a134..e986aac1f0 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/routes.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/routes.py @@ -817,16 +817,6 @@ async def presentation_exchange_verify_presentation(request: web.BaseRequest): ) ) - connection_id = pres_ex_record.connection_id - - try: - connection_record = await ConnRecord.retrieve_by_id(session, connection_id) - except StorageError as err: - raise web.HTTPBadRequest(reason=err.roll_up) from err - - if not connection_record.is_ready: - raise web.HTTPForbidden(reason=f"Connection {connection_id} not ready") - presentation_manager = PresentationManager(context.profile) try: pres_ex_record = await presentation_manager.verify_presentation(pres_ex_record) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py index f8335341c4..41424eb20e 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py @@ -1299,92 +1299,6 @@ async def test_presentation_exchange_verify_presentation_px_rec_not_found(self): ) assert "no such record" in str(context.exception) - async def test_presentation_exchange_verify_presentation_not_found(self): - self.request.match_info = {"pres_ex_id": "dummy"} - self.profile.context.injector.bind_instance( - BaseLedger, - async_mock.MagicMock( - __aenter__=async_mock.CoroutineMock(), - __aexit__=async_mock.CoroutineMock(), - ), - ) - self.profile.context.injector.bind_instance( - IndyVerifier, - async_mock.MagicMock( - verify_presentation=async_mock.CoroutineMock(), - ), - ) - - with async_mock.patch( - "aries_cloudagent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, async_mock.patch( - "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, async_mock.patch( - ( - "aries_cloudagent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" - ), - autospec=True, - ) as mock_presentation_exchange: - - # Since we are mocking import - importlib.reload(test_module) - - mock_presentation_exchange.retrieve_by_id = async_mock.CoroutineMock( - return_value=async_mock.MagicMock( - state=mock_presentation_exchange.STATE_PRESENTATION_RECEIVED, - connection_id="dummy", - ) - ) - - mock_connection_record.retrieve_by_id = async_mock.CoroutineMock( - side_effect=StorageNotFoundError - ) - - with self.assertRaises(test_module.web.HTTPBadRequest): - await test_module.presentation_exchange_verify_presentation( - self.request - ) - - async def test_presentation_exchange_verify_presentation_not_ready(self): - self.request.match_info = {"pres_ex_id": "dummy"} - - with async_mock.patch( - "aries_cloudagent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, async_mock.patch( - "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, async_mock.patch( - ( - "aries_cloudagent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" - ), - autospec=True, - ) as mock_presentation_exchange: - - # Since we are mocking import - importlib.reload(test_module) - - mock_presentation_exchange.retrieve_by_id = async_mock.CoroutineMock( - return_value=async_mock.MagicMock( - state=mock_presentation_exchange.STATE_PRESENTATION_RECEIVED, - connection_id="dummy", - ) - ) - - mock_connection_record.is_ready = False - mock_connection_record.retrieve_by_id = async_mock.CoroutineMock( - return_value=mock_connection_record - ) - - with self.assertRaises(test_module.web.HTTPForbidden): - await test_module.presentation_exchange_verify_presentation( - self.request - ) - async def test_presentation_exchange_verify_presentation_bad_state(self): self.request.json = async_mock.CoroutineMock() self.request.match_info = {"pres_ex_id": "dummy"} diff --git a/aries_cloudagent/protocols/present_proof/v2_0/routes.py b/aries_cloudagent/protocols/present_proof/v2_0/routes.py index 14024379d6..afcf317ab7 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/routes.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/routes.py @@ -1093,16 +1093,6 @@ async def present_proof_verify_presentation(request: web.BaseRequest): ) ) - connection_id = pres_ex_record.connection_id - - try: - conn_record = await ConnRecord.retrieve_by_id(session, connection_id) - except StorageError as err: - raise web.HTTPBadRequest(reason=err.roll_up) from err - - if not conn_record.is_ready: - raise web.HTTPForbidden(reason=f"Connection {connection_id} not ready") - pres_manager = V20PresManager(context.profile) try: pres_ex_record = await pres_manager.verify_pres(pres_ex_record) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/tests/test_routes.py b/aries_cloudagent/protocols/present_proof/v2_0/tests/test_routes.py index 297e9a0eda..6c54e7742f 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/tests/test_routes.py @@ -2082,59 +2082,6 @@ async def test_present_proof_verify_presentation_px_rec_not_found(self): await test_module.present_proof_verify_presentation(self.request) assert "no such record" in str(context.exception) - async def test_present_proof_verify_presentation_not_found(self): - self.request.match_info = {"pres_ex_id": "dummy"} - - with async_mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, async_mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: - mock_px_rec_inst = async_mock.MagicMock( - connection_id="dummy", - state=test_module.V20PresExRecord.STATE_PRESENTATION_RECEIVED, - serialize=async_mock.MagicMock( - return_value={"thread_id": "sample-thread-id"} - ), - ) - mock_px_rec_cls.retrieve_by_id = async_mock.CoroutineMock( - return_value=mock_px_rec_inst - ) - - mock_conn_rec_inst = async_mock.MagicMock(is_ready=True) - mock_conn_rec_cls.retrieve_by_id = async_mock.CoroutineMock( - side_effect=StorageNotFoundError() - ) - - with self.assertRaises(test_module.web.HTTPBadRequest): - await test_module.present_proof_verify_presentation(self.request) - - async def test_present_proof_verify_presentation_not_ready(self): - self.request.match_info = {"pres_ex_id": "dummy"} - - with async_mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, async_mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: - mock_px_rec_inst = async_mock.MagicMock( - connection_id="dummy", - state=test_module.V20PresExRecord.STATE_PRESENTATION_RECEIVED, - serialize=async_mock.MagicMock( - return_value={"thread_id": "sample-thread-id"} - ), - ) - mock_px_rec_cls.retrieve_by_id = async_mock.CoroutineMock( - return_value=mock_px_rec_inst - ) - mock_conn_rec_inst = async_mock.MagicMock(is_ready=False) - mock_conn_rec_cls.retrieve_by_id = async_mock.CoroutineMock( - return_value=mock_conn_rec_inst - ) - - with self.assertRaises(test_module.web.HTTPForbidden): - await test_module.present_proof_verify_presentation(self.request) - async def test_present_proof_verify_presentation_bad_state(self): self.request.match_info = {"pres_ex_id": "dummy"}