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

Import DynamicListForm fix from latest cockpit #1381

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ COCKPIT_REPO_FILES = \
$(NULL)

COCKPIT_REPO_URL = https://github.com/cockpit-project/cockpit.git
COCKPIT_REPO_COMMIT = cf2485d79da7fb9be262eaa4ca5ef91e57a03a75 # 308 + 5 commits
COCKPIT_REPO_COMMIT = e4dcf6b1272b65bfdec28d2027906beac9724b87 # 308 + 19 commits

$(COCKPIT_REPO_FILES): $(COCKPIT_REPO_STAMP)
COCKPIT_REPO_TREE = '$(strip $(COCKPIT_REPO_COMMIT))^{tree}'
Expand Down
2 changes: 1 addition & 1 deletion src/components/create-vm-dialog/createVmDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import { domainCreate } from '../../libvirtApi/domain.js';
import { storagePoolRefresh } from '../../libvirtApi/storagePool.js';
import { getAccessToken } from '../../libvirtApi/rhel-images.js';
import { PasswordFormFields, password_quality } from 'cockpit-components-password.jsx';
import { DynamicListForm } from 'DynamicListForm.jsx';
import { DynamicListForm } from 'cockpit-components-dynamic-list.jsx';

import './createVmDialog.scss';

Expand Down
45 changes: 45 additions & 0 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ NO_STORAGE = "No storage"
NEW_VOLUME_QCOW2 = "Create new qcow2 volume"
NEW_VOLUME_RAW = "Create new raw volume"

ED25519_PUB = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKIXL+o/1JPsH9Ftf3CtEPVFOpFxJIk4xYzTzkupkUNk a@test"


@testlib.nondestructive
class TestMachinesCreate(machineslib.VirtualMachinesCase):

# This test contains basic button and form validation of the Create VM dialog
# None of the sub-tests will actually call virt-install
def testCreateBasicValidation(self):
b = self.browser
runner = TestMachinesCreate.CreateVmRunner(self)
config = TestMachinesCreate.TestCreateConfig

Expand Down Expand Up @@ -206,6 +209,48 @@ class TestMachinesCreate(machineslib.VirtualMachinesCase):
ssh_keys=[rsakey]),
{"create-vm-dialog-user-login": "User login must not be empty when SSH keys are set"})

# Delete SSH keys
dialog = TestMachinesCreate.VmDialog(self, sourceType='cloud',
storage_size=10, storage_size_unit='MiB',
location=config.VALID_DISK_IMAGE_PATH,
user_login="admin",
ssh_keys=[rsakey])
dialog.open() \
.fill()

# initially we have the single rsakey
b.wait_in_text("#create-vm-dialog-ssh-key-0 #validated", "ssh-rsa")
self.assertFalse(b.is_present("#create-vm-dialog-ssh-key-1"))

# add two more empty ones
b.click("button:contains(Add SSH keys)")
b.wait_text_matches("#create-vm-dialog-ssh-key-1 textarea", "^$")
self.assertFalse(b.is_present("#create-vm-dialog-ssh-key-2"))

b.click("button:contains(Add SSH keys)")
b.wait_text_matches("#create-vm-dialog-ssh-key-2 textarea", "^$")
self.assertFalse(b.is_present("#create-vm-dialog-ssh-key-3"))

# delete the third (empty) one
b.click("#create-vm-dialog-ssh-key-2-btn-close")
b.wait_not_present("#create-vm-dialog-ssh-key-2")
# first two still exist
b.wait_visible("#create-vm-dialog-ssh-key-0 #validated")
b.wait_text_matches("#create-vm-dialog-ssh-key-1 textarea", "^$")

# now delete the first key
b.click("#create-vm-dialog-ssh-key-0-btn-close")
# only the second (empty) one exists now)
b.wait_not_present("#create-vm-dialog-ssh-key-0")
b.wait_text_matches("#create-vm-dialog-ssh-key-1 textarea", "^$")
b.wait_not_present("#create-vm-dialog-ssh-key-2")

# enter a valid EC key
b.set_input_text("#create-vm-dialog-ssh-key-1 textarea", ED25519_PUB, value_check=False)
b.wait_in_text("#create-vm-dialog-ssh-key-1 #validated", "ssh-ed25519")

dialog.cancel()

def testCreateNameGeneration(self):
config = TestMachinesCreate.TestCreateConfig
runner = TestMachinesCreate.CreateVmRunner(self)
Expand Down