Skip to content

Commit

Permalink
Don't show the system session option on limited access
Browse files Browse the repository at this point in the history
A limited access user cannot create a system session virtual machine so
this would just throw an error after creation.
  • Loading branch information
jelly committed Nov 22, 2024
1 parent 1da60f7 commit b3dcf68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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 @@ -2765,6 +2765,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")


if __name__ == '__main__':
testlib.test_main()

0 comments on commit b3dcf68

Please sign in to comment.