diff --git a/pytest_fixtures/component/provision_vmware.py b/pytest_fixtures/component/provision_vmware.py index 716e37bc951..e8c4439f6f6 100644 --- a/pytest_fixtures/component/provision_vmware.py +++ b/pytest_fixtures/component/provision_vmware.py @@ -72,6 +72,11 @@ def module_vmware_hostgroup( subnet=module_provisioning_sat.subnet, pxe_loader=pxe_loader.pxe_loader, group_parameters_attributes=[ + { + 'name': 'remote_execution_connect_by_ip', + 'parameter_type': 'boolean', + 'value': 'true', + }, # assign AK in order the hosts to be subscribed { 'name': 'kt_activation_keys', diff --git a/tests/foreman/api/test_computeresource_vmware.py b/tests/foreman/api/test_computeresource_vmware.py index 39731e9278a..fe158de6c7f 100644 --- a/tests/foreman/api/test_computeresource_vmware.py +++ b/tests/foreman/api/test_computeresource_vmware.py @@ -17,15 +17,16 @@ from wrapanapi.systems.virtualcenter import VMWareVirtualMachine from robottelo.config import settings +from robottelo.hosts import ContentHost @pytest.mark.e2e @pytest.mark.on_premises_provisioning @pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) @pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True) -@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) +@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi', 'secureboot'], indirect=True) @pytest.mark.parametrize('provision_method', ['build', 'bootdisk']) -@pytest.mark.rhel_ver_match('[8]') +@pytest.mark.rhel_ver_list('[9, 10]') def test_positive_provision_end_to_end( request, setting_update, @@ -33,6 +34,7 @@ def test_positive_provision_end_to_end( module_provisioning_sat, module_sca_manifest_org, module_location, + module_ssh_key_file, pxe_loader, module_vmware_cr, module_vmware_hostgroup, @@ -46,7 +48,6 @@ def test_positive_provision_end_to_end( :id: 6985e7c0-d258-4fc4-833b-e680804b55e8 :steps: - 1. Configure provisioning setup. 2. Create VMware CR 3. Configure host group setup. @@ -57,16 +58,26 @@ def test_positive_provision_end_to_end( :CaseImportance: Critical - :Verifies: SAT-23417, SAT-23558 + :Verifies: SAT-18721, SAT-23558, SAT-25810, SAT-25339 :customerscenario: true :BZ: 2186114 - - :verifies: SAT-18721 """ sat = module_provisioning_sat.sat name = gen_string('alpha').lower() + + # Add remote_execution_ssh_keys parameter in hostgroup for ssh connection to EL9/EL10 host + existing_params = module_vmware_hostgroup.group_parameters_attributes + module_vmware_hostgroup.group_parameters_attributes = [ + { + 'name': 'remote_execution_ssh_keys', + 'value': settings.provisioning.host_ssh_key_pub, + 'parameter_type': 'string', + }, + ] + existing_params + module_vmware_hostgroup.update(['group_parameters_attributes']) + host = sat.api.Host( hostgroup=module_vmware_hostgroup, organization=module_sca_manifest_org, @@ -78,10 +89,10 @@ def test_positive_provision_end_to_end( 'path': '/Datacenters/SatQE-Datacenter/vm/', 'cpus': 2, 'memory_mb': 6000, - 'firmware': 'bios' if pxe_loader.vm_firmware == 'bios' else 'efi', - 'cluster': f'{settings.vmware.cluster}', + 'firmware': pxe_loader.vm_firmware, + 'cluster': settings.vmware.cluster, 'start': '1', - 'guest_id': 'rhel8_64Guest', + 'guest_id': 'rhel9_64Guest', 'scsi_controllers': [{'type': 'ParaVirtualSCSIController', 'key': 1001}], 'nvme_controllers': [{'type': 'VirtualNVMEController', 'key': 2001}], 'volumes_attributes': { @@ -98,6 +109,7 @@ def test_positive_provision_end_to_end( 'controller_key': 1001, }, }, + 'virtual_tpm': 'false' if pxe_loader.vm_firmware == 'bios' else 'true', }, interfaces_attributes={ '0': { @@ -116,9 +128,15 @@ def test_positive_provision_end_to_end( request.addfinalizer(lambda: sat.provisioning_cleanup(host.name)) assert host.name == f'{name}.{module_provisioning_sat.domain.name}' - # check if vm is created on vmware + # Check if VM is created on VMware assert vmwareclient.does_vm_exist(host.name) is True - # check the build status + + # Check if virtual TPM device is added to created VM (only for UEFI) + if pxe_loader.vm_firmware != 'bios': + vm = vmwareclient.get_vm(host.name) + assert 'VirtualTPM' in vm.get_virtual_device_type_names() + + # Check the build status wait_for( lambda: host.read().build_status_label != 'Pending installation', timeout=1500, @@ -126,6 +144,21 @@ def test_positive_provision_end_to_end( ) assert host.read().build_status_label == 'Installed' + # Verify SecureBoot is enabled on host after provisioning is completed sucessfully + if pxe_loader.vm_firmware == 'uefi_secure_boot': + provisioning_host = ContentHost(host.ip, auth=module_ssh_key_file) + # Wait for the host to be rebooted and SSH daemon to be started. + provisioning_host.wait_for_connection() + # Enable Root Login + if int(host.operatingsystem.read().major) >= 9: + assert ( + provisioning_host.execute( + 'echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config; systemctl restart sshd' + ).status + == 0 + ) + assert 'SecureBoot enabled' in provisioning_host.execute('mokutil --sb-state').stdout + @pytest.mark.on_premises_provisioning @pytest.mark.parametrize('module_provisioning_sat', ['discovery'], indirect=True) diff --git a/tests/foreman/cli/test_computeresource_vmware.py b/tests/foreman/cli/test_computeresource_vmware.py index 333d1f6e646..1e6b162f760 100644 --- a/tests/foreman/cli/test_computeresource_vmware.py +++ b/tests/foreman/cli/test_computeresource_vmware.py @@ -17,6 +17,7 @@ from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS +from robottelo.hosts import ContentHost @pytest.mark.tier1 @@ -78,9 +79,9 @@ def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location, @pytest.mark.on_premises_provisioning @pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) @pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True) -@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) +@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi', 'secureboot'], indirect=True) @pytest.mark.parametrize('provision_method', ['build', 'bootdisk']) -@pytest.mark.rhel_ver_match(r'^(?!.*fips).*$') +@pytest.mark.rhel_ver_match('[7]') @pytest.mark.tier3 def test_positive_provision_end_to_end( request, @@ -101,7 +102,6 @@ def test_positive_provision_end_to_end( :id: ff9963fc-a2a7-4392-aa9a-190d5d1c8357 :steps: - 1. Configure provisioning setup. 2. Create VMware CR 3. Configure host group setup. @@ -110,7 +110,7 @@ def test_positive_provision_end_to_end( :expectedresults: Host is provisioned succesfully with hostgroup - :CaseAutomation: Automated + :Verifies: SAT-25810 """ sat = module_provisioning_sat.sat hostname = gen_string('alpha').lower() @@ -126,7 +126,7 @@ def test_positive_provision_end_to_end( 'compute-attributes': f'cluster={settings.vmware.cluster},' f'path=/Datacenters/{settings.vmware.datacenter}/vm/,' 'scsi_controller_type=VirtualLsiLogicController,' - 'guest_id=rhel8_64Guest,firmware=automatic,' + f'guest_id=rhel7_64Guest,firmware={pxe_loader.vm_firmware},' 'cpus=1,memory_mb=6000, start=1', 'interface': f'compute_type=VirtualVmxnet3,' f'compute_network=VLAN {settings.provisioning.vlan_id}', @@ -150,6 +150,13 @@ def test_positive_provision_end_to_end( host_info = sat.cli.Host.info({'id': host['id']}) assert host_info['status']['build-status'] == 'Installed' + # Verify SecureBoot is enabled on host after provisioning is completed sucessfully + if pxe_loader.vm_firmware == 'uefi_secure_boot': + provisioning_host = ContentHost(host_info['network']['ipv4-address']) + # Wait for the host to be rebooted and SSH daemon to be started. + provisioning_host.wait_for_connection() + assert 'SecureBoot enabled' in provisioning_host.execute('mokutil --sb-state').stdout + @pytest.mark.e2e @pytest.mark.on_premises_provisioning @@ -190,10 +197,6 @@ def test_positive_image_provision_end_to_end( """ sat = module_provisioning_sat.sat hostname = gen_string('alpha').lower() - module_vmware_hostgroup.group_parameters_attributes = [ - {'name': 'package_upgrade', 'value': 'false', 'parameter_type': 'boolean'} - ] - module_vmware_hostgroup.update(['group_parameters_attributes']) host = sat.cli.Host.create( { 'name': hostname, diff --git a/tests/foreman/ui/test_computeresource_vmware.py b/tests/foreman/ui/test_computeresource_vmware.py index 6994b3fe18a..a23ca1b55ee 100644 --- a/tests/foreman/ui/test_computeresource_vmware.py +++ b/tests/foreman/ui/test_computeresource_vmware.py @@ -326,7 +326,7 @@ def test_positive_vmware_custom_profile_end_to_end( cpus = ['2', '4', '6'] vm_memory = ['4000', '6000', '8000'] annotation_notes = gen_string('alpha') - firmware_type = ['Automatic', 'BIOS', 'UEFI'] + firmware_type = ['Automatic', 'BIOS', 'UEFI', 'UEFI Secure Boot'] resource_pool = VMWARE_CONSTANTS['pool'] folder = VMWARE_CONSTANTS['folder'] virtual_hw_version = VMWARE_CONSTANTS['virtualhw_version'] @@ -554,12 +554,8 @@ def test_positive_virt_card(session, target_sat, module_location, module_org, vm @pytest.mark.e2e @pytest.mark.on_premises_provisioning -@pytest.mark.parametrize( - 'setting_update', - ['remote_execution_connect_by_ip=True', 'destroy_vm_on_host_delete=True'], - indirect=True, -) -@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) +@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) +@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi', 'secureboot'], indirect=True) @pytest.mark.parametrize('provision_method', ['build']) @pytest.mark.rhel_ver_match('[8]') @pytest.mark.tier3 @@ -593,7 +589,7 @@ def test_positive_provision_end_to_end( :BZ: 2025523 - :Verifies: SAT-24780 + :Verifies: SAT-24780, SAT-25810 :customerscenario: true """ @@ -653,6 +649,14 @@ def test_positive_provision_end_to_end( assert values['Build']['Status'] == 'Installed' assert values['Execution']['Status'] == 'Last execution succeeded' + # Verify SecureBoot is enabled on host after provisioning is completed sucessfully + if pxe_loader.vm_firmware == 'uefi_secure_boot': + host = target_sat.api.Host().search(query={'host': host_name})[0].read() + provisioning_host = ContentHost(host.ip) + # Wait for the host to be rebooted and SSH daemon to be started. + provisioning_host.wait_for_connection() + assert 'SecureBoot enabled' in provisioning_host.execute('mokutil --sb-state').stdout + # Verify if assigned role is executed on the host, and correct host passwd is set host = ContentHost(target_sat.api.Host().search(query={'host': host_name})[0].read().ip) assert host.execute('yum list installed rubygem-foreman_scap_client').status == 0