Esempio n. 1
0
async def test_tab_login_logout(aqtbot, running_backend, gui_factory,
                                autoclose_dialog, client_config, alice):
    password = "******"
    save_device_with_password(client_config.config_dir, alice, password)
    gui = await gui_factory()

    assert gui.tab_center.count() == 1
    assert gui.tab_center.tabText(0) == translate(
        "TEXT_TAB_TITLE_LOG_IN_SCREEN")
    assert not gui.add_tab_button.isEnabled()
    first_created_tab = gui.test_get_tab()

    await gui.test_switch_to_logged_in(alice)
    assert gui.tab_center.count() == 1
    assert gui.tab_center.tabText(
        0) == "CoolOrg - Alicey McAliceFace - My dev1 machine"
    assert gui.add_tab_button.isEnabled()
    assert gui.test_get_tab() == first_created_tab

    await gui.test_logout()
    assert gui.tab_center.count() == 1
    assert gui.tab_center.tabText(0) == translate(
        "TEXT_TAB_TITLE_LOG_IN_SCREEN")
    assert not gui.add_tab_button.isEnabled()
    assert gui.test_get_tab() != first_created_tab
Esempio n. 2
0
async def test_tab_login_logout_two_tabs_logged_in(aqtbot, running_backend,
                                                   gui_factory,
                                                   autoclose_dialog,
                                                   client_config, alice, bob):
    password = "******"
    save_device_with_password(client_config.config_dir, alice, password)
    gui = await gui_factory()

    assert gui.tab_center.count() == 1
    assert gui.tab_center.tabText(0) == translate(
        "TEXT_TAB_TITLE_LOG_IN_SCREEN")

    await gui.test_switch_to_logged_in(alice)
    assert gui.tab_center.count() == 1
    assert gui.tab_center.tabText(
        0) == "CoolOrg - Alicey McAliceFace - My dev1 machine"
    alice_logged_tab = gui.test_get_tab()

    await aqtbot.mouse_click(gui.add_tab_button, QtCore.Qt.LeftButton)
    assert gui.tab_center.count() == 2
    assert gui.tab_center.tabText(
        0) == "CoolOrg - Alicey McAliceFace - My dev1 machine"
    assert gui.tab_center.tabText(1) == translate(
        "TEXT_TAB_TITLE_LOG_IN_SCREEN")

    save_device_with_password(client_config.config_dir, bob, password)
    await gui.test_switch_to_logged_in(bob)
    assert gui.tab_center.count() == 2
    assert gui.tab_center.tabText(
        0) == "CoolOrg - Alicey McAliceFace - My dev1 machine"
    assert gui.tab_center.tabText(
        1) == "CoolOrg - Boby McBobFace - My dev1 machine"
    bob_logged_tab = gui.test_get_tab()
    assert bob_logged_tab != alice_logged_tab

    gui.switch_to_tab(0)

    def _logged_tab_displayed():
        assert alice_logged_tab == gui.test_get_tab()

    await aqtbot.wait(200)

    await aqtbot.wait_until(_logged_tab_displayed)

    await gui.test_logout()
    assert gui.tab_center.count() == 2
    assert gui.tab_center.tabText(
        0) == "CoolOrg - Boby McBobFace - My dev1 machine"
    assert gui.tab_center.tabText(1) == translate(
        "TEXT_TAB_TITLE_LOG_IN_SCREEN")
Esempio n. 3
0
async def test_list_users_offline(aqtbot, logged_gui, autoclose_dialog):
    u_w = await logged_gui.test_switch_to_users_widget(error=True)
    assert u_w.layout_users.count() == 1
    error_msg = u_w.layout_users.itemAt(0).widget()
    assert isinstance(error_msg, QLabel)
    assert error_msg.text() == translate("TEXT_USER_LIST_RETRIEVABLE_FAILURE")
    assert not autoclose_dialog.dialogs
Esempio n. 4
0
        async def offline_step_5_provide_claim_info(self):
            expected_message = translate("TEXT_GREET_USER_GET_REQUESTS_ERROR")
            with running_backend.offline():
                await aqtbot.wait_until(
                    partial(self._greet_aborted, expected_message))

            return None
Esempio n. 5
0
        async def reset_step_3_exchange_greeter_sas(self):
            expected_message = translate("TEXT_GREET_DEVICE_PEER_RESET")
            async with self._reset_claimer():
                await aqtbot.wait_until(partial(self._greet_restart, expected_message))

            await self.bootstrap_after_restart()
            return None
Esempio n. 6
0
        async def offline_step_2_start_greeter(self):
            expected_message = translate("TEXT_CLAIM_USER_WAIT_PEER_ERROR")
            with running_backend.offline():
                await aqtbot.wait_until(
                    partial(self._claim_aborted, expected_message))

            return None
Esempio n. 7
0
        async def offline_step_6_validate_claim_info(self):
            expected_message = translate("TEXT_CLAIM_USER_CLAIM_ERROR")
            with running_backend.offline():
                await aqtbot.wait_until(
                    partial(self._claim_aborted, expected_message))

            return None
Esempio n. 8
0
 def _assert_error():
     assert len(autoclose_dialog.dialogs) == 2
     assert (
         "Error",
         translate("TEXT_WORKPACE_REENCRYPT_ACCESS_ERROR"),
     ) in autoclose_dialog.dialogs
     assert wk_button.button_reencrypt.isVisible()
Esempio n. 9
0
        async def cancelled_step_5_provide_claim_info(self):
            expected_message = translate("TEXT_GREET_DEVICE_WAIT_PEER_TRUST_ERROR")

            await self._cancel_invitation()
            await aqtbot.wait_until(partial(self._greet_restart, expected_message))

            return None
Esempio n. 10
0
async def test_workspace_reencryption_do_one_batch_error(
    aqtbot,
    running_backend,
    logged_gui,
    autoclose_dialog,
    monkeypatch,
    reencryption_needed_workspace,
    error_type,
    input_patcher,
):

    expected_errors = {
        FSBackendOfflineError:
        translate("TEXT_WORKPACE_REENCRYPT_OFFLINE_ERROR"),
        FSError:
        translate("TEXT_WORKPACE_REENCRYPT_FS_ERROR"),
        FSWorkspaceNoAccess:
        translate("TEXT_WORKPACE_REENCRYPT_ACCESS_ERROR"),
        FSWorkspaceNotFoundError:
        translate("TEXT_WORKPACE_REENCRYPT_NOT_FOUND_ERROR"),
        Exception:
        translate("TEXT_WORKSPACE_REENCRYPT_UNKOWN_ERROR"),
    }

    w_w = await logged_gui.test_switch_to_workspaces_widget()
    await display_reencryption_button(aqtbot, monkeypatch, w_w, input_patcher)

    wk_button = w_w.layout_workspaces.itemAt(0).widget()

    async def mocked_start_reencryption(self, workspace_id):
        class Job:
            async def do_one_batch(self, size=512):
                raise error_type("")

        return Job()

    w_w.client.user_fs.workspace_start_reencryption = mocked_start_reencryption.__get__(
        w_w.client.user_fs)
    await aqtbot.mouse_click(wk_button.button_reencrypt, QtCore.Qt.LeftButton)

    def _assert_error():
        assert len(autoclose_dialog.dialogs) == 1
        assert autoclose_dialog.dialogs == [("Error",
                                             expected_errors[error_type])]
        assert wk_button.button_reencrypt.isVisible()

    await aqtbot.wait_until(_assert_error)
Esempio n. 11
0
        async def cancelled_step_6_validate_claim_info(self):
            expected_message = translate("TEXT_CLAIM_USER_CLAIM_ERROR")
            await self._cancel_invitation()

            await aqtbot.wait_until(
                partial(self._claim_restart, expected_message))

            return None
Esempio n. 12
0
        async def reset_step_6_validate_claim_info(self):
            expected_message = translate("TEXT_CLAIM_USER_PEER_RESET")
            async with self._reset_greeter():
                await aqtbot.wait_until(
                    partial(self._claim_restart, expected_message))

            await self.bootstrap_after_restart()
            return None
Esempio n. 13
0
        async def cancelled_step_2_start_greeter(self):
            expected_message = translate("TEXT_CLAIM_USER_WAIT_PEER_ERROR")
            await self._cancel_invitation()

            await aqtbot.wait_until(
                partial(self._claim_restart, expected_message))

            return None
Esempio n. 14
0
        async def offline_step_4_exchange_claimer_sas(self):
            expected_message = translate(
                "TEXT_CLAIM_USER_WAIT_PEER_TRUST_ERROR")
            with running_backend.offline():
                await aqtbot.wait_until(
                    partial(self._claim_aborted, expected_message))

            return None
Esempio n. 15
0
        async def reset_step_5_provide_claim_info(self):
            expected_message = translate("TEXT_GREET_USER_PEER_RESET")
            async with self._reset_claimer():
                await aqtbot.wait_until(
                    partial(self._greet_restart, expected_message))

            await self.bootstrap_after_restart()
            return None
Esempio n. 16
0
        async def offline_step_4_exchange_claimer_sas(self):
            expected_message = translate("TEXT_GREET_DEVICE_SIGNIFY_TRUST_ERROR")
            guce_w = self.greet_device_code_exchange_widget

            with running_backend.offline():
                await aqtbot.run(guce_w.code_input_widget.good_code_clicked.emit)
                await aqtbot.wait_until(partial(self._greet_aborted, expected_message))

            return None
Esempio n. 17
0
        async def offline_step_1_start_greet(self):
            expected_message = translate("TEXT_GREET_DEVICE_WAIT_PEER_ERROR")
            gui_w = self.greet_device_information_widget

            with running_backend.offline():
                await aqtbot.mouse_click(gui_w.button_start, QtCore.Qt.LeftButton)
                await aqtbot.wait_until(partial(self._greet_aborted, expected_message))

            return None
Esempio n. 18
0
        async def cancelled_step_4_exchange_claimer_sas(self):
            expected_message = translate(
                "TEXT_CLAIM_USER_WAIT_PEER_TRUST_ERROR")
            await self._cancel_invitation()

            await aqtbot.wait_until(
                partial(self._claim_restart, expected_message))

            return None
Esempio n. 19
0
 def _check_info_displayed():
     assert guci_w.isVisible()
     assert guci_w.line_edit_user_full_name.text(
     ) == self.requested_human_handle.label
     assert guci_w.line_edit_user_email.text(
     ) == self.requested_human_handle.email
     assert guci_w.line_edit_device.text(
     ) == self.requested_device_label
     assert guci_w.label_warning.text() == translate(
         "TEXT_LABEL_USER_ROLE_RECOMMANDATIONS")
Esempio n. 20
0
        async def reset_step_4_exchange_claimer_sas(self):
            expected_message = translate(
                "TEXT_CLAIM_DEVICE_WAIT_PEER_TRUST_ERROR")
            async with self._reset_greeter():
                await aqtbot.wait_until(partial(self._claim_restart,
                                                expected_message),
                                        timeout=2000)

            await self.bootstrap_after_restart()
            return None
Esempio n. 21
0
        async def cancelled_step_1_start_greet(self):
            expected_message = translate("TEXT_GREET_DEVICE_WAIT_PEER_ERROR")
            gui_w = self.greet_device_information_widget

            await self._cancel_invitation()

            await aqtbot.mouse_click(gui_w.button_start, QtCore.Qt.LeftButton)
            await aqtbot.wait_until(partial(self._greet_restart, expected_message))

            return None
Esempio n. 22
0
        async def cancelled_step_4_exchange_claimer_sas(self):
            expected_message = translate("TEXT_GREET_DEVICE_SIGNIFY_TRUST_ERROR")
            guce_w = self.greet_device_code_exchange_widget

            await self._cancel_invitation()

            await aqtbot.run(guce_w.code_input_widget.good_code_clicked.emit)
            await aqtbot.wait_until(partial(self._greet_restart, expected_message))

            return None
Esempio n. 23
0
        async def cancelled_step_3_exchange_greeter_sas(self):
            expected_message = translate("TEXT_CLAIM_USER_SIGNIFY_TRUST_ERROR")
            cuce_w = self.claim_user_code_exchange_widget
            await self._cancel_invitation()

            await aqtbot.run(cuce_w.code_input_widget.good_code_clicked.emit)
            await aqtbot.wait_until(
                partial(self._claim_restart, expected_message))

            return None
Esempio n. 24
0
        async def offline_step_3_exchange_greeter_sas(self):
            expected_message = translate("TEXT_CLAIM_USER_SIGNIFY_TRUST_ERROR")
            cuce_w = self.claim_user_code_exchange_widget

            with running_backend.offline():
                assert not autoclose_dialog.dialogs
                await aqtbot.run(
                    cuce_w.code_input_widget.good_code_clicked.emit)
                await aqtbot.wait_until(
                    partial(self._claim_aborted, expected_message))
            return None
Esempio n. 25
0
        async def cancelled_step_1_start_claim(self):
            expected_message = translate("TEXT_CLAIM_USER_WAIT_PEER_ERROR")
            cui_w = self.claim_user_instructions_widget

            await self._cancel_invitation()

            await aqtbot.mouse_click(cui_w.button_start, QtCore.Qt.LeftButton)
            await aqtbot.wait_until(
                partial(self._claim_restart, expected_message))

            return None
Esempio n. 26
0
        async def offline_step_1_start_claim(self):
            expected_message = translate("TEXT_CLAIM_USER_WAIT_PEER_ERROR")
            cui_w = self.claim_user_instructions_widget

            with running_backend.offline():
                await aqtbot.mouse_click(cui_w.button_start,
                                         QtCore.Qt.LeftButton)
                await aqtbot.wait_until(
                    partial(self._claim_aborted, expected_message))

            return None
Esempio n. 27
0
        async def reset_step_4_exchange_claimer_sas(self):
            expected_message = translate("TEXT_GREET_DEVICE_PEER_RESET")
            guce_w = self.greet_device_code_exchange_widget

            # Pretent we have click on the right choice
            await aqtbot.run(guce_w.code_input_widget.good_code_clicked.emit)

            async with self._reset_claimer():
                await aqtbot.wait_until(partial(self._greet_restart, expected_message))

            await self.bootstrap_after_restart()
            return None
Esempio n. 28
0
        async def reset_step_3_exchange_greeter_sas(self):
            expected_message = translate("TEXT_CLAIM_USER_PEER_RESET")
            cuce_w = self.claim_user_code_exchange_widget

            async with self._reset_greeter():
                await aqtbot.run(
                    cuce_w.code_input_widget.good_code_clicked.emit)
                await aqtbot.wait_until(
                    partial(self._claim_restart, expected_message))

            await self.bootstrap_after_restart()
            return None
Esempio n. 29
0
        async def offline_step_6_validate_claim_info(self):
            expected_message = translate(
                "TEXT_GREET_USER_WAIT_PEER_TRUST_ERROR")
            guci_w = self.greet_user_check_informations_widget

            with running_backend.offline():
                self.nursery.cancel_scope.cancel()
                await aqtbot.mouse_click(guci_w.button_create_user,
                                         QtCore.Qt.LeftButton)
                await aqtbot.wait_until(
                    partial(self._greet_aborted, expected_message))

            return None
Esempio n. 30
0
        async def cancelled_step_6_validate_claim_info(self):
            expected_message = translate("TEXT_GREET_USER_CREATE_USER_ERROR")
            guci_w = self.greet_user_check_informations_widget
            with trio.fail_after(1):
                await self.claimer_claim_task.cancel_and_join()

            await self._cancel_invitation()

            await aqtbot.mouse_click(guci_w.button_create_user,
                                     QtCore.Qt.LeftButton)
            await aqtbot.wait_until(
                partial(self._greet_restart, expected_message))

            return None