async def test_receive_pres_bait_and_switch_attr_name(self):
    connection_record = async_mock.MagicMock(connection_id=CONN_ID)
    indy_proof_req = deepcopy(INDY_PROOF_REQ_NAME)
    indy_proof_req['requested_attributes']['1_screencapture_uuid']['restrictions'][0]['attr::screenCapture::value'] = 'EXAMPLE_KEY'
    indy_proof_x = {'proof': {'proofs': [{'primary_proof': {'eq_proof': '...', 'ge_proofs': [{'...': '...', 'predicate': {'attr_name': 'highscore', 'p_type': 'GE', 'value': 1000000}}]}}]}, 'requested_proof': {'revealed_attrs': {'0_player_uuid': {'sub_proof_index': 0, 'raw': 'Richie Knucklez', 'encoded': '12345678901234567890'}, '1_screencapture_uuid': {'sub_proof_index': 0, 'raw': 'bm90IHRoZSBzYW1lIHNjcmVlbiBjYXB0dXJl', 'encoded': '98765432109876543210'}}, 'self_attested_attrs': {}, 'unrevealed_attrs': {}, 'predicates': {'0_highscore_GE_uuid': {'sub_proof_index': 0}}}, 'identifiers': [{'schema_id': S_ID, 'cred_def_id': CD_ID, 'rev_reg_id': None, 'timestamp': None}]}
    pres_proposal = V20PresProposal(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_PROPOSAL][V20PresFormat.Format.INDY.api])], proposals_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_request = V20PresRequest(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_REQUEST][V20PresFormat.Format.INDY.api])], request_presentations_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_x = V20Pres(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], presentations_attach=[AttachDecorator.data_base64(indy_proof_x, ident='indy')])
    px_rec_dummy = V20PresExRecord(pres_proposal=pres_proposal.serialize(), pres_request=pres_request.serialize(), pres=pres_x.serialize())
    with async_mock.patch.object(V20PresExRecord, 'save', autospec=True) as save_ex, async_mock.patch.object(V20PresExRecord, 'retrieve_by_tag_filter', autospec=True) as retrieve_ex:
        retrieve_ex.return_value = px_rec_dummy
        with self.assertRaises(V20PresManagerError) as context:
            (await self.manager.receive_pres(pres_x, connection_record))
        assert ('does not satisfy proof request restrictions' in str(context.exception))
    indy_proof_req['requested_attributes']['shenanigans'] = indy_proof_req['requested_attributes'].pop('1_screencapture_uuid')
    pres_proposal = V20PresProposal(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_PROPOSAL][V20PresFormat.Format.INDY.api])], proposals_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_request = V20PresRequest(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], request_presentations_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_x = V20Pres(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], presentations_attach=[AttachDecorator.data_base64(indy_proof_x, ident='indy')])
    px_rec_dummy = V20PresExRecord(pres_proposal=pres_proposal.serialize(), pres_request=pres_request.serialize(), pres=pres_x.serialize())
    with async_mock.patch.object(V20PresExRecord, 'save', autospec=True) as save_ex, async_mock.patch.object(V20PresExRecord, 'retrieve_by_tag_filter', autospec=True) as retrieve_ex:
        retrieve_ex.return_value = px_rec_dummy
        with self.assertRaises(V20PresManagerError) as context:
            (await self.manager.receive_pres(pres_x, connection_record))
        assert ('Presentation referent' in str(context.exception))
async def test_receive_pres_bait_and_switch_attr_name(self):
    connection_record = async_mock.MagicMock(connection_id=CONN_ID)
    indy_proof_req = deepcopy(INDY_PROOF_REQ_NAME)
    indy_proof_req['requested_attributes']['1_screencapture_uuid']['restrictions'][0]['attr::screenCapture::value'] = 'EXAMPLE_KEY'
    indy_proof_x = {'proof': {'proofs': [{'primary_proof': {'eq_proof': '...', 'ge_proofs': [{'...': '...', 'predicate': {'attr_name': 'highscore', 'p_type': 'GE', 'value': 1000000}}]}}]}, 'requested_proof': {'revealed_attrs': {'0_player_uuid': {'sub_proof_index': 0, 'raw': 'Richie Knucklez', 'encoded': '12345678901234567890'}, '1_screencapture_uuid': {'sub_proof_index': 0, 'raw': 'bm90IHRoZSBzYW1lIHNjcmVlbiBjYXB0dXJl', 'encoded': '98765432109876543210'}}, 'self_attested_attrs': {}, 'unrevealed_attrs': {}, 'predicates': {'0_highscore_GE_uuid': {'sub_proof_index': 0}}}, 'identifiers': [{'schema_id': S_ID, 'cred_def_id': CD_ID, 'rev_reg_id': None, 'timestamp': None}]}
    pres_proposal = V20PresProposal(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_PROPOSAL][V20PresFormat.Format.INDY.api])], proposals_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_request = V20PresRequest(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_REQUEST][V20PresFormat.Format.INDY.api])], request_presentations_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_x = V20Pres(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], presentations_attach=[AttachDecorator.data_base64(indy_proof_x, ident='indy')])
    px_rec_dummy = V20PresExRecord(pres_proposal=pres_proposal.serialize(), pres_request=pres_request.serialize(), pres=pres_x.serialize())
    with async_mock.patch.object(V20PresExRecord, 'save', autospec=True) as save_ex, async_mock.patch.object(V20PresExRecord, 'retrieve_by_tag_filter', autospec=True) as retrieve_ex:
        retrieve_ex.return_value = px_rec_dummy
        with self.assertRaises(V20PresManagerError) as context:
            (await self.manager.receive_pres(pres_x, connection_record))
        assert ('does not satisfy proof request restrictions' in str(context.exception))
    indy_proof_req['requested_attributes']['shenanigans'] = indy_proof_req['requested_attributes'].pop('1_screencapture_uuid')
    pres_proposal = V20PresProposal(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_PROPOSAL][V20PresFormat.Format.INDY.api])], proposals_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_request = V20PresRequest(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], request_presentations_attach=[AttachDecorator.data_base64(indy_proof_req, ident='indy')])
    pres_x = V20Pres(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], presentations_attach=[AttachDecorator.data_base64(indy_proof_x, ident='indy')])
    px_rec_dummy = V20PresExRecord(pres_proposal=pres_proposal.serialize(), pres_request=pres_request.serialize(), pres=pres_x.serialize())
    with async_mock.patch.object(V20PresExRecord, 'save', autospec=True) as save_ex, async_mock.patch.object(V20PresExRecord, 'retrieve_by_tag_filter', autospec=True) as retrieve_ex:
        retrieve_ex.return_value = px_rec_dummy
        with self.assertRaises(V20PresManagerError) as context:
            (await self.manager.receive_pres(pres_x, connection_record))
        assert ('Presentation referent' in str(context.exception))