From e44bd508f3eb01157b4819c02f8ef1a27c44e491 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Mon, 8 Apr 2024 05:44:25 -0400 Subject: [PATCH] [6.15.z] HTTP Proxy UI fixes (#14669) --- tests/foreman/cli/test_leapp_client.py | 117 +++++++++++++++++++++---- tests/foreman/ui/test_http_proxy.py | 32 ++++--- 2 files changed, 117 insertions(+), 32 deletions(-) diff --git a/tests/foreman/cli/test_leapp_client.py b/tests/foreman/cli/test_leapp_client.py index 4ea36bbf37a..e6d9a51e910 100644 --- a/tests/foreman/cli/test_leapp_client.py +++ b/tests/foreman/cli/test_leapp_client.py @@ -77,14 +77,14 @@ def module_stash(request): @pytest.fixture(scope='module') -def module_leapp_lce(module_target_sat, module_sca_manifest_org): - return module_target_sat.api.LifecycleEnvironment(organization=module_sca_manifest_org).create() +def module_leapp_lce(module_target_sat, module_entitlement_manifest_org): + return module_target_sat.api.LifecycleEnvironment(organization=module_entitlement_manifest_org).create() @pytest.fixture -def function_leapp_cv(module_target_sat, module_sca_manifest_org, leapp_repos, module_leapp_lce): +def function_leapp_cv(module_target_sat, module_entitlement_manifest_org, leapp_repos, module_leapp_lce): function_leapp_cv = module_target_sat.api.ContentView( - organization=module_sca_manifest_org + organization=module_entitlement_manifest_org ).create() function_leapp_cv.repository = leapp_repos function_leapp_cv = function_leapp_cv.update(['repository']) @@ -99,12 +99,12 @@ def function_leapp_ak( module_target_sat, function_leapp_cv, module_leapp_lce, - module_sca_manifest_org, + module_entitlement_manifest_org, ): return module_target_sat.api.ActivationKey( content_view=function_leapp_cv, environment=module_leapp_lce, - organization=module_sca_manifest_org, + organization=module_entitlement_manifest_org, ).create() @@ -114,7 +114,7 @@ def leapp_repos( module_stash, upgrade_path, module_target_sat, - module_sca_manifest_org, + module_entitlement_manifest_org, ): """Enable and sync RHEL BaseOS, AppStream repositories""" source = upgrade_path['source_version'] @@ -130,7 +130,7 @@ def leapp_repos( module_stash[synced_repos][rh_repo_key] = True repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( basearch=default_architecture.name, - org_id=module_sca_manifest_org.id, + org_id=module_entitlement_manifest_org.id, product=PRDS[prod], repo=RHEL_REPOS[rh_repo_key]['name'], reposet=RHEL_REPOS[rh_repo_key]['reposet'], @@ -146,7 +146,7 @@ def leapp_repos( def verify_target_repo_on_satellite( module_target_sat, function_leapp_cv, - module_sca_manifest_org, + module_entitlement_manifest_org, module_leapp_lce, upgrade_path, ): @@ -156,7 +156,7 @@ def verify_target_repo_on_satellite( { 'search': f'content_label ~ rhel-{target_rhel_major_ver}', 'content-view-id': function_leapp_cv.id, - 'organization-id': module_sca_manifest_org.id, + 'organization-id': module_entitlement_manifest_org.id, 'lifecycle-environment-id': module_leapp_lce.id, } ) @@ -170,7 +170,7 @@ def verify_target_repo_on_satellite( @pytest.fixture -def custom_leapp_host(upgrade_path, module_target_sat, module_sca_manifest_org, function_leapp_ak): +def custom_leapp_host(upgrade_path, module_target_sat, module_entitlement_manifest_org, function_leapp_ak): """Checkout content host and register with satellite""" deploy_args = {} deploy_args['deploy_rhel_version'] = upgrade_path['source_version'] @@ -181,7 +181,7 @@ def custom_leapp_host(upgrade_path, module_target_sat, module_sca_manifest_org, deploy_flavor=settings.flavors.default, ) as chost: result = chost.register( - module_sca_manifest_org, None, function_leapp_ak.name, module_target_sat + module_entitlement_manifest_org, None, function_leapp_ak.name, module_target_sat ) assert result.status == 0, f'Failed to register host: {result.stderr}' yield chost @@ -199,6 +199,14 @@ def precondition_check_upgrade_and_install_leapp_tool(custom_leapp_host): assert custom_leapp_host.run('yum install leapp-upgrade -y').status == 0 if custom_leapp_host.run('needs-restarting -r').status == 1: custom_leapp_host.power_control(state='reboot', ensure=True) + if custom_leapp_host.os_version.major == 8: + # Inhibitor - Firewalld Configuration AllowZoneDrifting Is Unsupported + assert custom_leapp_host.run( + 'sed -i "s/^AllowZoneDrifting=.*/AllowZoneDrifting=no/" /etc/firewalld/firewalld.conf' + ).status == 0 + assert custom_leapp_host.run( + 'echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config; systemctl restart sshd' + ).status == 0 @pytest.mark.parametrize( @@ -233,12 +241,6 @@ def test_leapp_upgrade_rhel( :expectedresults: 1. Update RHEL OS major version to another major version """ - # Fixing known inhibitors for source rhel version 8 - if custom_leapp_host.os_version.major == 8: - # Inhibitor - Firewalld Configuration AllowZoneDrifting Is Unsupported - custom_leapp_host.run( - 'sed -i "s/^AllowZoneDrifting=.*/AllowZoneDrifting=no/" /etc/firewalld/firewalld.conf' - ) # Run LEAPP-PREUPGRADE Job Template- template_id = ( module_target_sat.api.JobTemplate() @@ -285,3 +287,82 @@ def test_leapp_upgrade_rhel( custom_leapp_host.clean_cached_properties() new_ver = str(custom_leapp_host.os_version) assert new_ver == upgrade_path['target_version'] + +@pytest.mark.parametrize( + 'upgrade_path', + [ + {'source_version': RHEL8_VER, 'target_version': RHEL9_VER}, + ], + ids=lambda upgrade_path: f'{upgrade_path["source_version"]}' + f'_to_{upgrade_path["target_version"]}', +) +def test_leapp_upgrade_rhel_non_admin( + module_target_sat, + module_entitlement_manifest_org, + default_location, + custom_leapp_host, + upgrade_path, + verify_target_repo_on_satellite, + precondition_check_upgrade_and_install_leapp_tool, +): + """Test to upgrade RHEL host to next major RHEL release using leapp preupgrade and leapp upgrade + job templates + + :id: afd295ca-4b0e-439f-b880-ae92c300fd9f + + :BZ: 2257302 + + :customerscenario: true + + :steps: + 1. Import a subscription manifest and enable, sync source & target repositories + 2. Create LCE, Create CV, add repositories to it, publish and promote CV, Create AK, etc. + 3. Register content host with AK + 4. Verify that target rhel repositories are enabled on Satellite + 5. Update all packages, install leapp tool and fix inhibitors + 6. Create a non-admin user with "Organization admin", "Remote Execution Manager" and "Remote Execution User" role assigned to it. + 7. Run Leapp Preupgrade and Leapp Upgrade job template from the user created in step 6. + + :expectedresults: + 1. Update RHEL OS major version to another major version from non-admin user role. + """ + login = gen_string('alpha') + password = gen_string('alpha') + roles = ['Organization admin', 'Remote Execution Manager', 'Remote Execution User'] + user = module_target_sat.cli_factory.user( + { + 'admin': False, + 'login': login, + 'password': password, + 'organization-ids': module_entitlement_manifest_org.id, + 'location-ids': default_location.id, + } + ) + for role in roles: + module_target_sat.cli.User.add_role({'id': user['id'], 'login': login, 'role': role}) + + invocation_command = module_target_sat.cli_factory.job_invocation_with_credentials( + { + 'job-template': 'Run preupgrade via Leapp', + 'search-query': f'name = {custom_leapp_host.hostname}', + 'organization-id': module_entitlement_manifest_org.id, + 'location-id': default_location.id, + }, + (login, password), + ) + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + assert result['success'] == '1' + + invocation_command = module_target_sat.cli_factory.job_invocation_with_credentials( + { + 'job-template': 'Run upgrade via Leapp', + 'search-query': f'name = {custom_leapp_host.hostname}', + 'organization-id': module_entitlement_manifest_org.id, + 'location-id': default_location.id, + 'inputs': 'Reboot=false', + }, + (login, password), + ) + custom_leapp_host.power_control(state='reboot') + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + assert result['success'] == '1' diff --git a/tests/foreman/ui/test_http_proxy.py b/tests/foreman/ui/test_http_proxy.py index a247058f8b6..10d2249be30 100644 --- a/tests/foreman/ui/test_http_proxy.py +++ b/tests/foreman/ui/test_http_proxy.py @@ -38,8 +38,6 @@ def test_positive_create_update_delete(module_org, module_location, target_sat): :id: 0c7cdf3d-778f-427a-9a2f-42ad7c23aa15 :expectedresults: All expected CRUD actions finished successfully - - :CaseImportance: High """ http_proxy_name = gen_string('alpha', 15) updated_proxy_name = gen_string('alpha', 15) @@ -65,8 +63,8 @@ def test_positive_create_update_delete(module_org, module_location, target_sat): assert http_proxy_values['http_proxy']['name'] == http_proxy_name assert http_proxy_values['http_proxy']['url'] == http_proxy_url assert http_proxy_values['http_proxy']['username'] == username - assert http_proxy_values['locations']['resources']['assigned'][0] == module_location.name - assert http_proxy_values['organizations']['resources']['assigned'][0] == module_org.name + assert module_location.name in http_proxy_values['locations']['resources']['assigned'] + assert module_org.name in http_proxy_values['organizations']['resources']['assigned'] # Update http_proxy with new name session.http_proxy.update(http_proxy_name, {'http_proxy.name': updated_proxy_name}) assert session.http_proxy.search(updated_proxy_name)[0]['Name'] == updated_proxy_name @@ -210,7 +208,7 @@ def test_set_default_http_proxy(module_org, module_location, setting_update, tar :steps: 1. Navigate to Infrastructure > Http Proxies 2. Create a Http Proxy - 3. GoTo to Administer > Settings > content tab + 3. Go to Administer > Settings > Content tab 4. Update the "Default HTTP Proxy" with created above. 5. Update "Default HTTP Proxy" to "no global default". @@ -251,29 +249,30 @@ def test_set_default_http_proxy(module_org, module_location, setting_update, tar def test_check_http_proxy_value_repository_details( function_org, function_location, function_product, setting_update, target_sat ): - """Deleted Global Http Proxy is reflected in repository details page". + """Global Http Proxy is reflected in repository details page". :id: 3f64255a-ef6c-4acb-b99b-e5579133b564 :steps: 1. Create Http Proxy (Go to Infrastructure > Http Proxies > New Http Proxy) - 2. GoTo to Administer > Settings > content tab + 2. Go to Administer > Settings > Content tab 3. Update the "Default HTTP Proxy" with created above. - 4. Create repository with Global Default Http Proxy. - 5. Delete the Http Proxy + 4. Create repository, check the Global Default Http Proxy is used. + 5. Delete the Http Proxy. + 6. Check it no longer appears on the Settings and repository page. :BZ: 1820193 :parametrized: yes :expectedresults: - 1. After deletion of "Default Http Proxy" its field on settings page should be - set to no global defult - 2. "HTTP Proxy" field in repository details page should be set to Global Default (None). + 1. Repository is automatically created with relevant Global Default Http Proxy. + 2. After Http Proxy deletion + - its field on Settings page should be set to Empty. + - "HTTP Proxy" field in repository details page should be set to Global Default (None). :CaseImportance: Medium """ - property_name = setting_update.name repo_name = gen_string('alpha') http_proxy_a = target_sat.api.HTTPProxy( @@ -297,10 +296,15 @@ def test_check_http_proxy_value_repository_details( 'repo_content.upstream_url': settings.repos.yum_0.url, }, ) + repo_values = session.repository.read(function_product.name, repo_name) + assert ( + repo_values['repo_content']['http_proxy_policy'] + == f'Global Default ({http_proxy_a.name})' + ) + session.http_proxy.delete(http_proxy_a.name) result = session.settings.read(f'name = {property_name}') assert result['table'][0]['Value'] == "Empty" - session.repository.search(function_product.name, repo_name)[0]['Name'] repo_values = session.repository.read(function_product.name, repo_name) assert repo_values['repo_content']['http_proxy_policy'] == 'Global Default (None)'