Skip to content

Commit b7d1e80

Browse files
committed
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). Finally, test copying 300k, which should be rejected regardless of the limit. Change also `zenity --entry` to `zenify --text-info --editable` as the former supports only up to 65535 characters. QubesOS/qubes-issues#9296
1 parent 4463bf6 commit b7d1e80

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

qubes/tests/integ/basic.py

+46-3
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,10 @@ def setUp(self):
472472
super(TC_30_Gui_daemon, self).setUp()
473473
self.init_default_template()
474474

475-
async def _test_clipboard(self, test_string):
475+
async def _test_clipboard(self, test_string,
476+
set_features=None,
477+
expect_content=None,
478+
expect_source_name=None):
476479
testvm1 = self.app.add_new_vm(
477480
qubes.vm.appvm.AppVM,
478481
name=self.make_vm_name('vm1'), label='red')
@@ -483,6 +486,9 @@ async def _test_clipboard(self, test_string):
483486
await testvm2.create_on_disk()
484487
self.app.save()
485488

489+
for feature, value in (set_features or {}).items():
490+
testvm1.features[feature] = value
491+
486492
await asyncio.gather(
487493
testvm1.start(),
488494
testvm2.start())
@@ -514,18 +520,23 @@ async def _test_clipboard(self, test_string):
514520

515521
clipboard_content = \
516522
open('/var/run/qubes/qubes-clipboard.bin', 'r').read().strip()
523+
524+
if expect_content is not None:
525+
test_string = expect_content
517526
self.assertEqual(clipboard_content, test_string,
518527
"Clipboard copy operation failed - content")
528+
if expect_source_name is None:
529+
expect_source_name = testvm1.name
519530
clipboard_source = \
520531
open('/var/run/qubes/qubes-clipboard.bin.source',
521532
'r').read().strip()
522-
self.assertEqual(clipboard_source, testvm1.name,
533+
self.assertEqual(clipboard_source, expect_source_name,
523534
"Clipboard copy operation failed - owner")
524535

525536
# Then paste it to the other window
526537
window_title = 'user@{}'.format(testvm2.name)
527538
p = await testvm2.run(
528-
'zenity --entry --title={} > /tmp/test.txt'.format(window_title))
539+
'zenity --text-info --editable --title={} > /tmp/test.txt'.format(window_title))
529540
await self.wait_for_window_coro(window_title)
530541

531542
subprocess.check_call(['xdotool', 'key', '--delay', '100',
@@ -553,6 +564,38 @@ def test_000_clipboard(self):
553564
test_string = "test123"
554565
self.loop.run_until_complete(self._test_clipboard(test_string))
555566

567+
@unittest.skipUnless(
568+
spawn.find_executable('xdotool'),
569+
"xdotool not installed")
570+
def test_001_clipboard_64k(self):
571+
test_string = "test123abc" * 6400
572+
self.loop.run_until_complete(self._test_clipboard(test_string))
573+
574+
@unittest.skipUnless(
575+
spawn.find_executable('xdotool'),
576+
"xdotool not installed")
577+
def test_002_clipboard_200k_truncated(self):
578+
test_string = "test123abc" * 20000
579+
self.loop.run_until_complete(self._test_clipboard(test_string,
580+
expect_content="", expect_source_name=""))
581+
582+
@unittest.skipUnless(
583+
spawn.find_executable('xdotool'),
584+
"xdotool not installed")
585+
def test_002_clipboard_200k(self):
586+
test_string = "test123abc" * 20000
587+
self.loop.run_until_complete(self._test_clipboard(test_string,
588+
set_features={"gui-max-clipboard-size": 200_000}))
589+
590+
@unittest.skipUnless(
591+
spawn.find_executable('xdotool'),
592+
"xdotool not installed")
593+
def test_002_clipboard_300k(self):
594+
test_string = "test123abc" * 30000
595+
self.loop.run_until_complete(self._test_clipboard(test_string,
596+
expect_content="Qube clipboard size over 256KiB and X11 INCR "
597+
"protocol support is not implemented!"))
598+
556599

557600
class TC_05_StandaloneVMMixin(object):
558601
def setUp(self):

0 commit comments

Comments
 (0)