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 <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-02-05 14:37:15 -05:00
parent 150b6ac95e
commit 01eb65bd61
11 changed files with 28 additions and 67 deletions

View File

@ -44,8 +44,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type='kvm'>+107:+107</baselabel>
<baselabel type='qemu'>+107:+107</baselabel>
<baselabel type='kvm'>+0:+0</baselabel>
<baselabel type='qemu'>+0:+0</baselabel>
</secmodel>
</host>

View File

@ -41,8 +41,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type='kvm'>+107:+107</baselabel>
<baselabel type='qemu'>+107:+107</baselabel>
<baselabel type='kvm'>+0:+0</baselabel>
<baselabel type='qemu'>+0:+0</baselabel>
</secmodel>
</host>

View File

@ -235,8 +235,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type='kvm'>+107:+107</baselabel>
<baselabel type='qemu'>+107:+107</baselabel>
<baselabel type='kvm'>+0:+0</baselabel>
<baselabel type='qemu'>+0:+0</baselabel>
</secmodel>
</host>

View File

@ -43,8 +43,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type="kvm">+107:+107</baselabel>
<baselabel type="qemu">+107:+107</baselabel>
<baselabel type="kvm">+0:+0</baselabel>
<baselabel type="qemu">+0:+0</baselabel>
</secmodel>
</host>

View File

@ -42,8 +42,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type="kvm">+107:+107</baselabel>
<baselabel type="qemu">+107:+107</baselabel>
<baselabel type="kvm">+0:+0</baselabel>
<baselabel type="qemu">+0:+0</baselabel>
</secmodel>
</host>

View File

@ -77,8 +77,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type='kvm'>+107:+107</baselabel>
<baselabel type='qemu'>+107:+107</baselabel>
<baselabel type='kvm'>+0:+0</baselabel>
<baselabel type='qemu'>+0:+0</baselabel>
</secmodel>
</host>

View File

@ -73,8 +73,8 @@
<secmodel>
<model>dac</model>
<doi>0</doi>
<baselabel type='kvm'>+107:+107</baselabel>
<baselabel type='qemu'>+107:+107</baselabel>
<baselabel type='kvm'>+0:+0</baselabel>
<baselabel type='qemu'>+0:+0</baselabel>
</secmodel>
</host>

View File

@ -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, [])

View File

@ -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

View File

@ -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)

View File

@ -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