From 01eb65bd6185c2ddddd50254cc20997cf8ca23c6 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 5 Feb 2020 14:37:15 -0500 Subject: [PATCH] tests: Don't report UID/GID in fake caps data Otherwise uitests can have different behavior depending on host state Signed-off-by: Cole Robinson --- tests/data/capabilities/kvm-aarch64.xml | 4 +- tests/data/capabilities/kvm-armv7l.xml | 4 +- tests/data/capabilities/kvm-ppc64le.xml | 4 +- tests/data/capabilities/kvm-s390x-KVMIBM.xml | 4 +- tests/data/capabilities/kvm-s390x.xml | 4 +- tests/data/capabilities/kvm-x86_64-rhel7.xml | 4 +- tests/data/capabilities/kvm-x86_64.xml | 4 +- tests/test_xmlconfig.py | 3 +- tests/uitests/test_addhardware.py | 44 -------------------- tests/uitests/test_livetests.py | 17 +++++--- virtinst/diskbackend.py | 3 -- 11 files changed, 28 insertions(+), 67 deletions(-) diff --git a/tests/data/capabilities/kvm-aarch64.xml b/tests/data/capabilities/kvm-aarch64.xml index c1aa1e03f..9b558c1cd 100644 --- a/tests/data/capabilities/kvm-aarch64.xml +++ b/tests/data/capabilities/kvm-aarch64.xml @@ -44,8 +44,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/data/capabilities/kvm-armv7l.xml b/tests/data/capabilities/kvm-armv7l.xml index 3f8ff1dbf..d9cc091f7 100644 --- a/tests/data/capabilities/kvm-armv7l.xml +++ b/tests/data/capabilities/kvm-armv7l.xml @@ -41,8 +41,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/data/capabilities/kvm-ppc64le.xml b/tests/data/capabilities/kvm-ppc64le.xml index 7338c3ec9..19f33447f 100644 --- a/tests/data/capabilities/kvm-ppc64le.xml +++ b/tests/data/capabilities/kvm-ppc64le.xml @@ -235,8 +235,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/data/capabilities/kvm-s390x-KVMIBM.xml b/tests/data/capabilities/kvm-s390x-KVMIBM.xml index f57278fc7..09764a067 100644 --- a/tests/data/capabilities/kvm-s390x-KVMIBM.xml +++ b/tests/data/capabilities/kvm-s390x-KVMIBM.xml @@ -43,8 +43,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/data/capabilities/kvm-s390x.xml b/tests/data/capabilities/kvm-s390x.xml index 039c2e0d8..b79c0924a 100644 --- a/tests/data/capabilities/kvm-s390x.xml +++ b/tests/data/capabilities/kvm-s390x.xml @@ -42,8 +42,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/data/capabilities/kvm-x86_64-rhel7.xml b/tests/data/capabilities/kvm-x86_64-rhel7.xml index d1c72fa08..3729097e5 100644 --- a/tests/data/capabilities/kvm-x86_64-rhel7.xml +++ b/tests/data/capabilities/kvm-x86_64-rhel7.xml @@ -77,8 +77,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/data/capabilities/kvm-x86_64.xml b/tests/data/capabilities/kvm-x86_64.xml index c08249933..6043c7d87 100644 --- a/tests/data/capabilities/kvm-x86_64.xml +++ b/tests/data/capabilities/kvm-x86_64.xml @@ -73,8 +73,8 @@ dac 0 - +107:+107 - +107:+107 + +0:+0 + +0:+0 diff --git a/tests/test_xmlconfig.py b/tests/test_xmlconfig.py index 5753f8675..3735daa0f 100644 --- a/tests/test_xmlconfig.py +++ b/tests/test_xmlconfig.py @@ -216,7 +216,8 @@ class TestXMLMisc(unittest.TestCase): # Use our uid, verify it shows we have expected access _set_caps_baselabel_uid(os.getuid()) - searchdata = virtinst.DeviceDisk.check_path_search(conn, tmpdir) + searchdata = virtinst.DeviceDisk.check_path_search(conn, + tmpdir + "/footest") self.assertEqual(searchdata.uid, os.getuid()) self.assertEqual(searchdata.fixlist, []) diff --git a/tests/uitests/test_addhardware.py b/tests/uitests/test_addhardware.py index afaf50920..bfa1ccbc8 100644 --- a/tests/uitests/test_addhardware.py +++ b/tests/uitests/test_addhardware.py @@ -2,7 +2,6 @@ # See the COPYING file in the top-level directory. import os -import tempfile import tests from tests.uitests import utils as uiutils @@ -107,49 +106,6 @@ class AddHardware(uiutils.UITestCase): disk_path = tab.find("disk-source-path") self.assertTrue("rbd://" in disk_path.text) - def _testQemuSearchCheck(self, filename): - """ - Use fake KVM URI, create a tmpdir with bad perms, make sure - UI offers to fix it, and initiate the fix - """ - self.app.uri = tests.utils.URIs.kvm - details = self._open_details_window() - addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") - - # Launch addhw, storage, file chooser - tab = self._select_hw(addhw, "Storage", "storage-tab") - tab.find_fuzzy("Select or create", "radio").click() - tab.find("storage-browse", "push button").click() - browse = self.app.root.find("Choose Storage Volume", "frame") - browse.find("Browse Local", "push button").click() - chooser = self.app.root.find( - "Locate existing storage", "file chooser") - - # Enter the filename and select it - chooser.find("Name", "text").text = filename - obutton = chooser.find("Open", "push button") - uiutils.check_in_loop(lambda: obutton.sensitive) - obutton.click() - uiutils.check_in_loop(lambda: not chooser.showing) - uiutils.check_in_loop(lambda: addhw.active) - finish.click() - - # Verify permission dialog pops up, ask to change - alert = self.app.root.find("vmm dialog", "alert") - alert.find("The emulator may not have search permissions") - alert.find("Yes", "push button").click() - - # Verify no errors - uiutils.check_in_loop(lambda: not addhw.showing) - uiutils.check_in_loop(lambda: details.active) - - def testQemuSearchCheck(self): - with tempfile.TemporaryDirectory() as tmpdir: - with tempfile.NamedTemporaryFile(dir=tmpdir) as tmpfile: - os.chmod(tmpdir, 0o700) - self._testQemuSearchCheck(tmpfile.name) - def testAddDisks(self): """ Add various disk configs and test storage browser diff --git a/tests/uitests/test_livetests.py b/tests/uitests/test_livetests.py index 9f1fc12a0..b3e1d0e8c 100644 --- a/tests/uitests/test_livetests.py +++ b/tests/uitests/test_livetests.py @@ -184,6 +184,15 @@ class Console(uiutils.UITestCase): tab.find("SCSI", "menu item").click() addhw.find("Finish", "push button").click() + # Verify permission dialog pops up, ask to change + alert = self.app.root.find("vmm dialog", "alert") + alert.find("The emulator may not have search permissions") + alert.find("Yes", "push button").click() + + # Verify no errors + uiutils.check_in_loop(lambda: not addhw.showing) + uiutils.check_in_loop(lambda: win.active) + # Hot unplug the disk win.find("SCSI Disk 1", "table cell").click() tab = win.find("disk-tab", None) @@ -216,17 +225,15 @@ class Console(uiutils.UITestCase): Live test for basic hotplugging and media change, as well as testing our auto-poolify magic """ - - import shutil import tempfile - dname = tempfile.mkdtemp(prefix="uitests-tmp") + tmpdir = tempfile.TemporaryDirectory(prefix="uitests-tmp") + dname = tmpdir.name try: fname = os.path.join(dname, "test.img") os.system("qemu-img create -f qcow2 %s 1M > /dev/null" % fname) - os.system("chmod -R 777 %s" % dname) + os.system("chmod 700 %s" % dname) self._testLiveHotplug(fname) finally: - shutil.rmtree(dname) poolname = os.path.basename(dname) try: pool = self.conn.storagePoolLookupByName(poolname) diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py index 5bb975509..ebef74169 100644 --- a/virtinst/diskbackend.py +++ b/virtinst/diskbackend.py @@ -301,9 +301,6 @@ def _is_dir_searchable(dirname, uid, username): """ Check if passed directory is searchable by uid """ - if "VIRTINST_TEST_SUITE" in os.environ: - return True - try: statinfo = os.stat(dirname) except OSError: # pragma: no cover