@@ -1400,6 +1400,164 @@ async def test_receive_pres_receive_pred_value_mismatch_punt_to_indy(self):
14001400 save_ex .assert_called_once ()
14011401 assert px_rec_out .state == (V20PresExRecord .STATE_PRESENTATION_RECEIVED )
14021402
1403+ async def test_receive_pres_indy_no_predicate_restrictions (self ):
1404+ connection_record = async_mock .MagicMock (connection_id = CONN_ID )
1405+ indy_proof_req = {
1406+ "name" : PROOF_REQ_NAME ,
1407+ "version" : PROOF_REQ_VERSION ,
1408+ "nonce" : PROOF_REQ_NONCE ,
1409+ "requested_attributes" : {
1410+ "0_player_uuid" : {
1411+ "name" : "player" ,
1412+ "restrictions" : [{"cred_def_id" : CD_ID }],
1413+ "non_revoked" : {"from" : NOW , "to" : NOW },
1414+ },
1415+ "0_screencapture_uuid" : {
1416+ "name" : "screenCapture" ,
1417+ "restrictions" : [{"cred_def_id" : CD_ID }],
1418+ "non_revoked" : {"from" : NOW , "to" : NOW },
1419+ },
1420+ },
1421+ "requested_predicates" : {
1422+ "0_highscore_GE_uuid" : {
1423+ "name" : "highScore" ,
1424+ "p_type" : ">=" ,
1425+ "p_value" : 1000000 ,
1426+ "restrictions" : [],
1427+ "non_revoked" : {"from" : NOW , "to" : NOW },
1428+ }
1429+ },
1430+ }
1431+ pres_request = V20PresRequest (
1432+ formats = [
1433+ V20PresFormat (
1434+ attach_id = "indy" ,
1435+ format_ = ATTACHMENT_FORMAT [PRES_20_REQUEST ][
1436+ V20PresFormat .Format .INDY .api
1437+ ],
1438+ )
1439+ ],
1440+ request_presentations_attach = [
1441+ AttachDecorator .data_base64 (indy_proof_req , ident = "indy" )
1442+ ],
1443+ )
1444+ pres = V20Pres (
1445+ formats = [
1446+ V20PresFormat (
1447+ attach_id = "indy" ,
1448+ format_ = ATTACHMENT_FORMAT [PRES_20 ][V20PresFormat .Format .INDY .api ],
1449+ )
1450+ ],
1451+ presentations_attach = [
1452+ AttachDecorator .data_base64 (INDY_PROOF , ident = "indy" )
1453+ ],
1454+ )
1455+ pres .assign_thread_id ("thread-id" )
1456+
1457+ px_rec_dummy = V20PresExRecord (
1458+ pres_request = pres_request .serialize (),
1459+ )
1460+
1461+ # cover by_format property
1462+ by_format = px_rec_dummy .by_format
1463+
1464+ assert by_format .get ("pres_request" ).get ("indy" ) == indy_proof_req
1465+
1466+ with async_mock .patch .object (
1467+ V20PresExRecord , "save" , autospec = True
1468+ ) as save_ex , async_mock .patch .object (
1469+ V20PresExRecord , "retrieve_by_tag_filter" , autospec = True
1470+ ) as retrieve_ex , async_mock .patch .object (
1471+ self .profile ,
1472+ "session" ,
1473+ async_mock .MagicMock (return_value = self .profile .session ()),
1474+ ) as session :
1475+ retrieve_ex .side_effect = [px_rec_dummy ]
1476+ px_rec_out = await self .manager .receive_pres (pres , connection_record , None )
1477+ retrieve_ex .assert_called_once_with (
1478+ session .return_value ,
1479+ {"thread_id" : "thread-id" },
1480+ {"role" : V20PresExRecord .ROLE_VERIFIER , "connection_id" : CONN_ID },
1481+ )
1482+ save_ex .assert_called_once ()
1483+ assert px_rec_out .state == (V20PresExRecord .STATE_PRESENTATION_RECEIVED )
1484+
1485+ async def test_receive_pres_indy_no_attr_restrictions (self ):
1486+ connection_record = async_mock .MagicMock (connection_id = CONN_ID )
1487+ indy_proof_req = {
1488+ "name" : PROOF_REQ_NAME ,
1489+ "version" : PROOF_REQ_VERSION ,
1490+ "nonce" : PROOF_REQ_NONCE ,
1491+ "requested_attributes" : {
1492+ "0_player_uuid" : {
1493+ "name" : "player" ,
1494+ "restrictions" : [],
1495+ "non_revoked" : {"from" : NOW , "to" : NOW },
1496+ }
1497+ },
1498+ "requested_predicates" : {},
1499+ }
1500+ proof = deepcopy (INDY_PROOF )
1501+ proof ["requested_proof" ]["revealed_attrs" ] = {
1502+ "0_player_uuid" : {
1503+ "sub_proof_index" : 0 ,
1504+ "raw" : "Richie Knucklez" ,
1505+ "encoded" : "516439982" ,
1506+ }
1507+ }
1508+ proof ["requested_proof" ]["predicates" ] = {}
1509+ pres_request = V20PresRequest (
1510+ formats = [
1511+ V20PresFormat (
1512+ attach_id = "indy" ,
1513+ format_ = ATTACHMENT_FORMAT [PRES_20_REQUEST ][
1514+ V20PresFormat .Format .INDY .api
1515+ ],
1516+ )
1517+ ],
1518+ request_presentations_attach = [
1519+ AttachDecorator .data_base64 (indy_proof_req , ident = "indy" )
1520+ ],
1521+ )
1522+ pres = V20Pres (
1523+ formats = [
1524+ V20PresFormat (
1525+ attach_id = "indy" ,
1526+ format_ = ATTACHMENT_FORMAT [PRES_20 ][V20PresFormat .Format .INDY .api ],
1527+ )
1528+ ],
1529+ presentations_attach = [AttachDecorator .data_base64 (proof , ident = "indy" )],
1530+ )
1531+ pres .assign_thread_id ("thread-id" )
1532+
1533+ px_rec_dummy = V20PresExRecord (
1534+ pres_request = pres_request .serialize (),
1535+ )
1536+
1537+ # cover by_format property
1538+ by_format = px_rec_dummy .by_format
1539+
1540+ assert by_format .get ("pres_request" ).get ("indy" ) == indy_proof_req
1541+
1542+ with async_mock .patch .object (
1543+ V20PresExRecord , "save" , autospec = True
1544+ ) as save_ex , async_mock .patch .object (
1545+ V20PresExRecord , "retrieve_by_tag_filter" , autospec = True
1546+ ) as retrieve_ex , async_mock .patch .object (
1547+ self .profile ,
1548+ "session" ,
1549+ async_mock .MagicMock (return_value = self .profile .session ()),
1550+ ) as session :
1551+ retrieve_ex .side_effect = [px_rec_dummy ]
1552+ px_rec_out = await self .manager .receive_pres (pres , connection_record , None )
1553+ retrieve_ex .assert_called_once_with (
1554+ session .return_value ,
1555+ {"thread_id" : "thread-id" },
1556+ {"role" : V20PresExRecord .ROLE_VERIFIER , "connection_id" : CONN_ID },
1557+ )
1558+ save_ex .assert_called_once ()
1559+ assert px_rec_out .state == (V20PresExRecord .STATE_PRESENTATION_RECEIVED )
1560+
14031561 async def test_receive_pres_bait_and_switch_attr_name (self ):
14041562 connection_record = async_mock .MagicMock (connection_id = CONN_ID )
14051563 indy_proof_req = deepcopy (INDY_PROOF_REQ_NAME )
0 commit comments