Skip to content

Commit 0e0a1c8

Browse files
committed
Update Whonix-Workstation file open and dispvm open tests
Whonix-Workstation now presents a qrexec confirmation prompt to the user before opening files in a DispVM or existing Whonix-Workstation VM. Explicitly confirm these actions in the appropriate tests.
1 parent 36fee27 commit 0e0a1c8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

qubes/tests/integ/dispvm.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,41 @@ def _handle_editor(self, winid, copy=False):
879879
else:
880880
raise KeyError(window_title)
881881

882+
def _whonix_ws_dispvm_confirm(self, action_str):
883+
try:
884+
winid = self.wait_for_window(
885+
"Operation execution",
886+
search_class=True,
887+
include_tray=False,
888+
timeout=5,
889+
)
890+
except Exception:
891+
return (
892+
False,
893+
"Failed to find qrexec confirmation window for "
894+
f"{action_str} action",
895+
)
896+
try:
897+
subprocess.run(
898+
[
899+
"bash",
900+
"-c",
901+
"--",
902+
f"xdotool windowfocus {winid}; sleep 1.1; "
903+
"xdotool key enter",
904+
],
905+
check=True,
906+
)
907+
except subprocess.CalledProcessError as err:
908+
return (
909+
False,
910+
"Failed to activate qrexec confirmation window for "
911+
"{} action: exit code {}, {}{}".format(
912+
action_str, err.returncode, err.stdout, err.stderr
913+
),
914+
)
915+
return (True, "")
916+
882917
@unittest.skipUnless(
883918
spawn.find_executable("xdotool"), "xdotool not installed"
884919
)
@@ -905,6 +940,11 @@ def test_030_edit_file(self):
905940
)
906941
)
907942

943+
if "whonix-workstation" in self.template:
944+
dvm_confirm_rslt = self._whonix_ws_dispvm_confirm("edit file")
945+
if not dvm_confirm_rslt[0]:
946+
self.fail(dvm_confirm_rslt[1])
947+
908948
# if first 5 windows isn't expected editor, there is no hope
909949
winid = None
910950
for _ in range(5):
@@ -1074,6 +1114,11 @@ def test_100_open_in_dispvm(self):
10741114
)
10751115
)
10761116

1117+
if "whonix-workstation" in self.template:
1118+
dvm_confirm_rslt = self._whonix_ws_dispvm_confirm("DispVM open")
1119+
if not dvm_confirm_rslt[0]:
1120+
self.fail(dvm_confirm_rslt[1])
1121+
10771122
# if first 5 windows isn't expected editor, there is no hope
10781123
winid = None
10791124
for _ in range(5):

0 commit comments

Comments
 (0)