mirror of
https://github.com/virt-manager/virt-manager.git
synced 2026-07-29 23:58:20 -05:00
uitests: Add connection login console lookup testing
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
@@ -105,3 +105,8 @@ class UITestConnection(uiutils.UITestCase):
|
|||||||
uiutils.check(lambda: not dialog.showing)
|
uiutils.check(lambda: not dialog.showing)
|
||||||
self._click_alert_button("Unable to connect", "Close")
|
self._click_alert_button("Unable to connect", "Close")
|
||||||
manager.find("test testdriver.xml - Not Connected", "table cell")
|
manager.find("test testdriver.xml - Not Connected", "table cell")
|
||||||
|
|
||||||
|
def testConnectionSessionError(self):
|
||||||
|
self.app.open(
|
||||||
|
extra_opts=["--test-options=fake-session-error"])
|
||||||
|
self._click_alert_button("Could not detect a local session", "Close")
|
||||||
|
|||||||
@@ -915,6 +915,11 @@ class vmmConnection(vmmGObject):
|
|||||||
data = self
|
data = self
|
||||||
if self.config.CLITestOptions.fake_openauth:
|
if self.config.CLITestOptions.fake_openauth:
|
||||||
testmock.fake_openauth(self, cb, data)
|
testmock.fake_openauth(self, cb, data)
|
||||||
|
if self.config.CLITestOptions.fake_session_error:
|
||||||
|
lerr = libvirt.libvirtError("fake session error")
|
||||||
|
lerr.err = [libvirt.VIR_ERR_AUTH_FAILED, None,
|
||||||
|
"fake session error not authorized"]
|
||||||
|
raise lerr
|
||||||
self._backend.open(cb, data)
|
self._backend.open(cb, data)
|
||||||
return True, None
|
return True, None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -935,8 +940,9 @@ class vmmConnection(vmmGObject):
|
|||||||
log.debug("Looks like we might have failed policykit "
|
log.debug("Looks like we might have failed policykit "
|
||||||
"auth. Checking to see if we have a valid "
|
"auth. Checking to see if we have a valid "
|
||||||
"console session")
|
"console session")
|
||||||
if (not self.is_remote() and
|
if not self.is_remote():
|
||||||
not connectauth.do_we_have_session()):
|
warnconsole = bool(not connectauth.do_we_have_session())
|
||||||
|
if self.config.CLITestOptions.fake_session_error:
|
||||||
warnconsole = True
|
warnconsole = True
|
||||||
|
|
||||||
ConnectError = connectauth.connect_error(
|
ConnectError = connectauth.connect_error(
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ class CLITestOptionsClass:
|
|||||||
* fake-nodedev-event: Fake nodedev API events
|
* fake-nodedev-event: Fake nodedev API events
|
||||||
* fake-openauth: Fake user+pass response from libvirt openauth,
|
* fake-openauth: Fake user+pass response from libvirt openauth,
|
||||||
for testing the TCP URI auth dialog
|
for testing the TCP URI auth dialog
|
||||||
|
* fake-session-error: Fake a connection open error that
|
||||||
|
triggers logind session lookup
|
||||||
"""
|
"""
|
||||||
def __init__(self, test_options_str):
|
def __init__(self, test_options_str):
|
||||||
optset = set()
|
optset = set()
|
||||||
@@ -208,6 +210,7 @@ class CLITestOptionsClass:
|
|||||||
self.fake_agent_event = _get_value("fake-agent-event")
|
self.fake_agent_event = _get_value("fake-agent-event")
|
||||||
self.fake_nodedev_event = _get_value("fake-nodedev-event")
|
self.fake_nodedev_event = _get_value("fake-nodedev-event")
|
||||||
self.fake_openauth = _get("fake-openauth")
|
self.fake_openauth = _get("fake-openauth")
|
||||||
|
self.fake_session_error = _get("fake-session-error")
|
||||||
|
|
||||||
if optset: # pragma: no cover
|
if optset: # pragma: no cover
|
||||||
raise RuntimeError("Unknown --test-options keys: %s" % optset)
|
raise RuntimeError("Unknown --test-options keys: %s" % optset)
|
||||||
|
|||||||
Reference in New Issue
Block a user