Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont show system session for user #1917

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/create-vm-dialog/createVmDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { ExternalLinkAltIcon, TrashIcon } from '@patternfly/react-icons';

import { DialogsContext } from 'dialogs.jsx';
import { useInit } from "hooks.js";
import { superuser } from "superuser.js";
import cockpit from 'cockpit';
import store from "../../store.js";
import { MachinesConnectionSelector } from '../common/machinesConnectionSelector.jsx';
Expand Down Expand Up @@ -1056,7 +1057,7 @@ class CreateVmModal extends React.Component {
validate: false,
vmName: '',
suggestedVmName: '',
connectionName: LIBVIRT_SYSTEM_CONNECTION,
connectionName: superuser.allowed ? LIBVIRT_SYSTEM_CONNECTION : LIBVIRT_SESSION_CONNECTION,
sourceType: defaultSourceType,
source: '',
os: undefined,
Expand Down Expand Up @@ -1331,12 +1332,13 @@ class CreateVmModal extends React.Component {

const detailsTab = (
<>
{superuser.allowed &&
<MachinesConnectionSelector
id='connection'
connectionName={this.state.connectionName}
onValueChanged={this.onValueChanged}
loggedUser={loggedUser}
showInfoHelper />
showInfoHelper />}
<SourceRow
connectionName={this.state.connectionName}
networks={networks.filter(network => network.connectionName == this.state.connectionName)}
Expand Down
19 changes: 19 additions & 0 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -2787,6 +2787,25 @@ vnc_password= "{vnc_passwd}"
b.wait_text(f"#vm-{vmName}-system-state", "Running")
b.wait_not_present(f"#vm-{vmName}-system-state-error")

def testNoSystemOptionOnLimitedAccess(self):
b = self.browser

self.login_and_go("/machines")
self.waitPageInit()

b.click("#create-new-vm")
b.wait_visible("#create-vm-dialog")
b.wait_visible("#connectionName-system")
b.click("#create-vm-dialog .pf-v5-c-button.pf-m-link")
b.wait_not_present("#create-vm-dialog")

b.drop_superuser()
self.waitPageInit()

b.click("#create-new-vm")
b.wait_visible("#create-vm-dialog")
b.wait_not_present("#connection")
Comment on lines +2805 to +2807
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any other test which covers VM creation in unprivileged mode? If so, this would better fit there. If not, that's a major gap indeed, and this test should actually create the VM and check that it starts and boots fine (including the "wait for login prompt").

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is confusingly what TestMachinesLifecycle does:

    def _testBasic(self, user=None, superuser=True, expect_empty_list=False, run_pixel_tests=False):
        b = self.browser
        m = self.machine

        # We want no initial watchdog
        args = self.createVm("subVmTest1", os="linux2016")

        self.login_and_go("/machines", user=user, superuser=superuser)

So we can drop this test



if __name__ == '__main__':
testlib.test_main()
5 changes: 3 additions & 2 deletions test/check-machines-lifecycle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ class TestMachinesLifecycle(machineslib.VirtualMachinesCase):
b.wait_in_text(".pf-v5-c-popover__body", message)
m.execute("virt-xml subVmTest1 --remove-device --watchdog 1 --update")

checkConnectionDescription("#import-existing-vm", "Ideal for server VMs")
checkConnectionDescription("#create-new-vm", "Good choice for desktop virtualization")
if superuser:
checkConnectionDescription("#import-existing-vm", "Ideal for server VMs")
checkConnectionDescription("#create-new-vm", "Good choice for desktop virtualization")
checkNeedsShutdownLabel("Watchdog")

b.wait_in_text("#vm-subVmTest1-system-state", "Running")
Expand Down