Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/317'
Browse files Browse the repository at this point in the history
* origin/pr/317:
  Avoid spaces in values for `admin.vm.Create` calls
  • Loading branch information
marmarek committed Nov 14, 2024
2 parents 1a6399b + 177cd2e commit 32e977b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qubesadmin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ def add_new_vm(self, cls, name, label, template=None, pool=None,
elif template is not None:
template = str(template)

if ' ' in name:
raise ValueError(f'Qube name could not contain space: {name}')
if pool and pools:
raise ValueError('only one of pool= and pools= can be used')

Expand Down
4 changes: 4 additions & 0 deletions qubesadmin/tests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,10 @@ def test_050_automatic_reset_cache(self):
self.assertEqual(vm.get_power_state(), 'Halted')
self.assertAllCalled()

def test_051_space_in_vmname(self):
with self.assertRaises(ValueError):
self.app.add_new_vm('AppVM', 'VM Name with spaces', 'red')


class TC_20_QubesLocal(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 32e977b

Please sign in to comment.