From 6b8a18985651179af4c508539b893f075246766a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 13 Oct 2024 17:51:39 +0200 Subject: [PATCH] test: extend clipboard tests to various different sizes Check if copying 64k also works. And then try copying 200kb, both with default settings (should be refused) and with limit raised. This test assume already modified behavior on over the limit copy (truncate to 0 instead of truncating to the limit). QubesOS/qubes-issues#9296 --- qubes/tests/integ/basic.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/qubes/tests/integ/basic.py b/qubes/tests/integ/basic.py index ed8e37cc6..3950414aa 100644 --- a/qubes/tests/integ/basic.py +++ b/qubes/tests/integ/basic.py @@ -472,7 +472,9 @@ def setUp(self): super(TC_30_Gui_daemon, self).setUp() self.init_default_template() - async def _test_clipboard(self, test_string): + async def _test_clipboard(self, test_string, + set_features=None, + expect_truncated_to=None): testvm1 = self.app.add_new_vm( qubes.vm.appvm.AppVM, name=self.make_vm_name('vm1'), label='red') @@ -483,6 +485,9 @@ async def _test_clipboard(self, test_string): await testvm2.create_on_disk() self.app.save() + for feature, value in (set_features or {}).items(): + testvm1.features[feature] = value + await asyncio.gather( testvm1.start(), testvm2.start()) @@ -514,6 +519,9 @@ async def _test_clipboard(self, test_string): clipboard_content = \ open('/var/run/qubes/qubes-clipboard.bin', 'r').read().strip() + + if expect_truncated_to is not None: + test_string = test_string[:expect_truncated_to] self.assertEqual(clipboard_content, test_string, "Clipboard copy operation failed - content") clipboard_source = \ @@ -553,6 +561,29 @@ def test_000_clipboard(self): test_string = "test123" self.loop.run_until_complete(self._test_clipboard(test_string)) + @unittest.skipUnless( + spawn.find_executable('xdotool'), + "xdotool not installed") + def test_001_clipboard_64k(self): + test_string = "test123abc" * 6400 + self.loop.run_until_complete(self._test_clipboard(test_string)) + + @unittest.skipUnless( + spawn.find_executable('xdotool'), + "xdotool not installed") + def test_002_clipboard_200k_truncated(self): + test_string = "test123abc" * 20000 + self.loop.run_until_complete(self._test_clipboard(test_string, + expect_truncated_to=0)) + + @unittest.skipUnless( + spawn.find_executable('xdotool'), + "xdotool not installed") + def test_002_clipboard_200k(self): + test_string = "test123abc" * 20000 + self.loop.run_until_complete(self._test_clipboard(test_string, + set_features={"gui-max-clipboard-size": 200_000})) + class TC_05_StandaloneVMMixin(object): def setUp(self):