From 3acd5a99a55f6730f1df121e3cdec7f579422da2 Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Thu, 21 Nov 2024 18:32:32 +0100 Subject: [PATCH] Add test_invited_invite_info_ok_with_shamir test --- .../tests/api_v4/invited/test_invite_info.py | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/server/tests/api_v4/invited/test_invite_info.py b/server/tests/api_v4/invited/test_invite_info.py index 31f7d3492cf..a389de9035c 100644 --- a/server/tests/api_v4/invited/test_invite_info.py +++ b/server/tests/api_v4/invited/test_invite_info.py @@ -2,8 +2,9 @@ import pytest -from parsec._parsec import invited_cmds -from tests.common import CoolorgRpcClients, HttpCommonErrorsTester +from parsec._parsec import authenticated_cmds, invited_cmds +from tests.common import CoolorgRpcClients, HttpCommonErrorsTester, ShamirOrgRpcClients +from tests.common.client import InvitedRpcClient @pytest.mark.parametrize("user_or_device", ("user", "device")) @@ -32,6 +33,40 @@ async def test_invited_invite_info_ok(user_or_device: str, coolorg: CoolorgRpcCl assert False, unknown +async def test_invited_invite_info_ok_with_shamir(shamirorg: ShamirOrgRpcClients) -> None: + # TODO: add `TestbedEventNewShamirRecoveryInvitation` event + rep = await shamirorg.bob.invite_new_shamir_recovery( + send_email=False, + claimer_user_id=shamirorg.alice.user_id, + ) + assert isinstance(rep, authenticated_cmds.v4.invite_new_shamir_recovery.RepOk) + + shamir_invited_bob = InvitedRpcClient(shamirorg.raw_client, shamirorg.organization_id, rep) # type: ignore + rep = await shamir_invited_bob.invite_info() + assert rep == invited_cmds.v4.invite_info.RepOk( + invited_cmds.v4.invite_info.UserOrDeviceShamirRecovery( + threshold=2, + recipients=[ + invited_cmds.latest.invite_info.ShamirRecoveryRecipient( + user_id=shamirorg.bob.user_id, + human_handle=shamirorg.bob.human_handle, + shares=2, + ), + invited_cmds.latest.invite_info.ShamirRecoveryRecipient( + user_id=shamirorg.mallory.user_id, + human_handle=shamirorg.mallory.human_handle, + shares=1, + ), + invited_cmds.latest.invite_info.ShamirRecoveryRecipient( + user_id=shamirorg.mike.user_id, + human_handle=shamirorg.mike.human_handle, + shares=1, + ), + ], + ) + ) + + async def test_invited_invite_info_http_common_errors( coolorg: CoolorgRpcClients, invited_http_common_errors_tester: HttpCommonErrorsTester ) -> None: