diff --git a/conf/fam.yaml.template b/conf/fam.yaml.template new file mode 100644 index 00000000000..079225d0048 --- /dev/null +++ b/conf/fam.yaml.template @@ -0,0 +1,101 @@ +FAM: + SERVER: + # Parameter for all tests + foreman_username: admin + foreman_password: "changeme" + foreman_server_url: "https://foreman.example.com" + foreman_validate_certs: false + + foreman_proxy: "foreman.example.com" + + # Parameter for snapshot test + snapshot_host_name: "test_host" + + # Parameter for job invocation test + foreman_host: "foreman.example.com" + + # Parameter for subscription_manifest test + subscription_manifest_path: "data/manifest_foreman-ansible-modules.zip" + + # Parameter for redhat_manifest test + manifest_name: "katello.example.com" + rhsm_username: "john-smith" + rhsm_password: "changeme" + rhsm_pool_id: 8a85f99a7db4827d017dc512fcad00b0 + rhsm_validate_certs: false + + # Parameter for scc_product test + scc_account_name_for_scc_product: testaccount + scc_account_login_for_scc_product: testuser + scc_account_password_for_scc_product: testpass + + # Parameter for external_usergroup testing + auth_source_ldap_host: ldap.example.com + auth_source_ldap_account: ansible + auth_source_ldap_account_password: pass + auth_source_ldap_base_dn: dc=example,dc=com + auth_source_ldap_attr_login: uid + auth_source_ldap_groups_base: cn=groups,cn=accounts,dc=example,dc=com + external_usergroup_name: "admins" + + COMPUTE_PROFILE: + libvirt: + compute_resource: + name: libvirt-cr01 + organizations: + - Test Organization + locations: + - Test Location + params: + url: qemu+ssh://libvirtuser@localhost/system + compute_profile: + name: app-small + attrs: + cpus: 1 + memory: 2147483648 + nics_attributes: + 0: + type: bridge + bridge: "" + model: virtio + volumes_attributes: + 0: + pool_name: default + capacity: 10G + allocation: 0G + format_type: raw + ovirt: + compute_resource: + name: ovirt-cr01 + organizations: + - Test Organization + locations: + - Test Location + params: + url: "https://ovirt.example.com/ovirt-engine/api" + user: compute-user@internal + password: ovirtcompute123 + use_v4: true + datacenter: c1479626-99a2-44eb-8401-14b5630f417f + ovirt_quota: 502a76bb-a3fe-42f1-aed6-2a7c892a6786 + compute_profile: + name: app-small + attrs: + cluster: Devel-Infra + cores: 2 + sockets: 1 + memory: 1073741824 + ha: 0 + interfaces_attributes: + 0: + name: "" + network: ovirtmgmt + interface: virtio + volumes_attributes: + 0: + size_gb: '16' + storage_domain: 'Local-IBM' + preallocate: '1' + wipe_after_delete: '0' + interface: 'virtio_scsi' + bootable: 'true' diff --git a/conf/supportability.yaml b/conf/supportability.yaml index 5e6c6680895..81fab5824f9 100644 --- a/conf/supportability.yaml +++ b/conf/supportability.yaml @@ -1,4 +1,5 @@ supportability: content_hosts: + default_os_name: "RedHat" rhel: versions: [6, 7,'7_fips', 8, '8_fips', 9, '9_fips'] diff --git a/pytest_fixtures/component/os.py b/pytest_fixtures/component/os.py index af64b0b0883..82a62269955 100644 --- a/pytest_fixtures/component/os.py +++ b/pytest_fixtures/component/os.py @@ -2,7 +2,7 @@ from nailgun import entities import pytest -from robottelo import constants +from robottelo.config import settings @pytest.fixture(scope='session') @@ -10,25 +10,26 @@ def default_os( default_architecture, default_partitiontable, default_pxetemplate, - request, + session_target_sat, ): - """Returns an Operating System entity read from searching Redhat family - - Indirect parametrization should pass an operating system version string like 'RHEL 7.9' - Default operating system will find the first RHEL6 or RHEL7 entity - """ - os = getattr(request, 'param', None) - if os is None: - search_string = constants.DEFAULT_OS_SEARCH_QUERY - else: - version = os.split(' ')[1].split('.') - search_string = f'family="Redhat" AND major="{version[0]}" AND minor="{version[1]}"' - os = entities.OperatingSystem().search(query={'search': search_string})[0].read() + """Returns an Operating System entity read from searching for supportability.content_host.default_os_name""" + search_string = f'name="{settings.supportability.content_hosts.default_os_name}"' + + try: + os = ( + session_target_sat.api.OperatingSystem() + .search(query={'search': search_string})[0] + .read() + ) + except IndexError as e: + raise RuntimeError(f"Could not find operating system for '{search_string}'") from e + os.architecture.append(default_architecture) os.ptable.append(default_partitiontable) os.provisioning_template.append(default_pxetemplate) os.update(['architecture', 'ptable', 'provisioning_template']) - return entities.OperatingSystem(id=os.id).read() + + return session_target_sat.api.OperatingSystem(id=os.id).read() @pytest.fixture(scope='module') @@ -38,8 +39,6 @@ def module_os(): @pytest.fixture(scope='module') def os_path(default_os): - from robottelo.config import settings - # Check what OS was found to use correct media if default_os.major == "6": os_distr_url = settings.repos.rhel6_os diff --git a/requirements.txt b/requirements.txt index 8c521b30b9b..15fe6f6b26f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,11 +3,11 @@ apypie==0.4.0 betelgeuse==1.11.0 broker[docker]==0.4.9 -cryptography==42.0.5 +cryptography==42.0.7 deepdiff==7.0.1 dynaconf[vault]==3.2.5 fauxfactory==3.1.1 -jinja2==3.1.3 +jinja2==3.1.4 manifester==0.0.14 navmazing==1.2.2 productmd==1.38 diff --git a/robottelo/config/validators.py b/robottelo/config/validators.py index 1a6a6d7f4aa..a47dba2e211 100644 --- a/robottelo/config/validators.py +++ b/robottelo/config/validators.py @@ -4,7 +4,10 @@ VALIDATORS = dict( supportability=[ - Validator('supportability.content_hosts.rhel.versions', must_exist=True, is_type_of=list) + Validator('supportability.content_hosts.rhel.versions', must_exist=True, is_type_of=list), + Validator( + 'supportability.content_hosts.default_os_name', must_exist=True, default='RedHat' + ), ], server=[ Validator('server.hostname', default=''), diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index b3cfcdd8f38..05571d2c3e3 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1894,7 +1894,6 @@ class Colored(Box): "content_export_repository", "content_export_version", "content_rhel_role", - "content_upload_ostree", "content_upload", "content_view_filter_info", "content_view_filter_rule_info", @@ -1955,9 +1954,9 @@ class Colored(Box): "puppet_environment", "realm", "redhat_manifest", + "registration_command", "repositories_role", "repository_info", - "repository_ostree", "repository_set_info", "repository_set", "repository_sync", @@ -1984,6 +1983,7 @@ class Colored(Box): "usergroup", "user", "wait_for_task", + "webhook", ] FAM_ROOT_DIR = '/usr/share/ansible/collections/ansible_collections/redhat/satellite' diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 72dc0bb392d..57dec9e9f04 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -883,12 +883,17 @@ def get(self, remote_path, local_path=None): """Get a remote file from the broker virtual machine.""" self.session.sftp_read(source=remote_path, destination=local_path) - def put(self, local_path, remote_path=None): + def put(self, local_path, remote_path=None, temp_file=False): """Put a local file to the broker virtual machine. If local_path is a manifest object, write its contents to a temporary file then continue with the upload. """ - if 'utils.manifest' in str(local_path): + if temp_file: + with NamedTemporaryFile(dir=robottelo_tmp_dir) as content_file: + content_file.write(str.encode(local_path)) + content_file.flush() + self.session.sftp_write(source=content_file.name, destination=remote_path) + elif 'utils.manifest' in str(local_path): with NamedTemporaryFile(dir=robottelo_tmp_dir) as content_file: content_file.write(local_path.content.read()) content_file.flush() diff --git a/tests/foreman/destructive/test_ansible.py b/tests/foreman/destructive/test_ansible.py index 28f6e932099..f48b7e996b0 100644 --- a/tests/foreman/destructive/test_ansible.py +++ b/tests/foreman/destructive/test_ansible.py @@ -12,6 +12,7 @@ """ +from fauxfactory import gen_string import pytest pytestmark = [pytest.mark.destructive, pytest.mark.upgrade] @@ -69,3 +70,50 @@ def test_positive_import_all_roles(target_sat): # by default should work here. session.ansibleroles.delete('theforeman.foreman_scap_client') assert not session.ansibleroles.search('theforeman.foreman_scap_client') + + +@pytest.mark.parametrize('setting_update', ['entries_per_page=12'], indirect=True) +def test_positive_hostgroup_ansible_roles_tab_pagination(target_sat, setting_update): + """Import all Ansible roles available by default. + + :id: 53fe3857-a08f-493d-93c7-3fed331ed392 + + :steps: + 1. Navigate to the Configure > Roles page, and click the `Import from [hostname]` button + 2. Get total number of importable roles from pagination. + 3. Fill the `Select All` checkbox and click the `Submit` button + 4. Verify that number of imported roles == number of importable roles from step 2 + 5. Navigate to Administer > Settings > General tab and update the entries_per_page setting + 6. Navigate to `Ansible Roles` tab in Hostgroup create and edit page + 7. Verify the new per page entry is updated in pagination list + + :expectedresults: All imported roles should be available on the webUI and properly paginated + as per entries_per_page setting on create and edit hostgroup page. + + :BZ: 2166466, 2242915 + + :customerscenario: true + """ + setting_value = str( + target_sat.api.Setting().search(query={'search': 'name=entries_per_page'})[0].value + ) + with target_sat.ui_session() as session: + imported_roles = session.ansibleroles.import_all_roles() + total_role_count = str(session.ansibleroles.imported_roles_count) + assert imported_roles == int(total_role_count) + assert total_role_count > setting_value + + create_page = session.hostgroup.helper.read_filled_view( + 'New', read_widget_names=['ansible_roles.pagination'] + ) + assert create_page['ansible_roles']['pagination']['_items'].split()[2] == setting_value + assert create_page['ansible_roles']['pagination']['_items'].split()[-2] == total_role_count + + hg = target_sat.api.HostGroup(name=gen_string('alpha')).create() + edit_page = session.hostgroup.helper.read_filled_view( + 'Edit', + navigation_kwargs={'entity_name': hg.name}, + read_widget_names=['ansible_roles.pagination'], + ) + assert edit_page['ansible_roles']['pagination']['_items'].split()[2] == setting_value + assert edit_page['ansible_roles']['pagination']['_items'].split()[-2] == total_role_count diff --git a/tests/foreman/destructive/test_ldap_authentication.py b/tests/foreman/destructive/test_ldap_authentication.py index 050ae241d0f..485fc620365 100644 --- a/tests/foreman/destructive/test_ldap_authentication.py +++ b/tests/foreman/destructive/test_ldap_authentication.py @@ -130,7 +130,7 @@ def configure_hammer_session(parametrized_enrolled_sat, enable=True): def generate_otp(secret): """Return the time_based_otp""" - time_otp = pyotp.TOTP(secret) + time_otp = pyotp.TOTP(secret, digest='SHA1', digits=6, interval=120) return time_otp.now() @@ -569,7 +569,9 @@ def test_user_permissions_rhsso_user_multiple_group( assert login_details['username'] in current_user -def test_totp_user_login(ad_data, module_target_sat): +def test_totp_user_login( + enable_external_auth_rhsso, rhsso_setting_setup, ad_data, module_target_sat +): """Verify the TOTP authentication of LDAP user interlinked with RH-SSO :id: cf8dfa00-4f48-11eb-b7d5-d46d6dd3b5b2 diff --git a/tests/foreman/sys/test_fam.py b/tests/foreman/sys/test_fam.py index e4675d4f581..a797c39d792 100644 --- a/tests/foreman/sys/test_fam.py +++ b/tests/foreman/sys/test_fam.py @@ -46,6 +46,19 @@ def setup_fam(module_target_sat, module_sca_manifest): # Execute AAP WF for FAM setup Broker().execute(workflow='fam-test-setup', source_vm=module_target_sat.name) + # Setup provisioning resources and copy config files to the Satellite + module_target_sat.configure_libvirt_cr() + module_target_sat.put( + settings.fam.server.to_yaml(), + f'{FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml', + temp_file=True, + ) + module_target_sat.put( + settings.fam.compute_profile.to_yaml(), + f'{FAM_ROOT_DIR}/tests/test_playbooks/vars/compute_profile.yml', + temp_file=True, + ) + # Edit Makefile to not try to rebuild the collection when tests run module_target_sat.execute(f"sed -i '/^live/ s/$(MANIFEST)//' {FAM_ROOT_DIR}/Makefile") @@ -54,27 +67,10 @@ def setup_fam(module_target_sat, module_sca_manifest): module_target_sat.execute( f'mv {module_sca_manifest.name} {FAM_ROOT_DIR}/tests/test_playbooks/data' ) - - # Edit config file config_file = f'{FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml' - module_target_sat.execute( - f'cp {FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml.example {config_file}' - ) - module_target_sat.execute( - f'sed -i "s/foreman.example.com/{module_target_sat.hostname}/g" {config_file}' - ) - module_target_sat.execute( - f'sed -i "s/rhsm_pool_id:.*/rhsm_pool_id: {settings.subscription.rhn_poolid}/g" {config_file}' - ) - module_target_sat.execute( - f'''sed -i 's/rhsm_username:.*/rhsm_username: "{settings.subscription.rhn_username}"/g' {config_file}''' - ) module_target_sat.execute( f'''sed -i 's|subscription_manifest_path:.*|subscription_manifest_path: "data/{module_sca_manifest.name}"|g' {config_file}''' ) - module_target_sat.execute( - f'''sed -i 's/rhsm_password:.*/rhsm_password: "{settings.subscription.rhn_password}"/g' {config_file}''' - ) @pytest.mark.pit_server