From 536a6af14357aaf8c1d9013626613309625ed47a Mon Sep 17 00:00:00 2001 From: yanpliu Date: Fri, 12 Jan 2024 11:03:02 -0500 Subject: [PATCH] http proxy create location option support (#13768) (cherry picked from commit 2512f9722485aefc06194f0a27a45a2e74f2e016) --- robottelo/utils/virtwho.py | 3 ++- tests/foreman/virtwho/api/test_esx.py | 8 +++++--- tests/foreman/virtwho/api/test_esx_sca.py | 8 +++++--- tests/foreman/virtwho/cli/test_esx.py | 8 +++++--- tests/foreman/virtwho/cli/test_esx_sca.py | 11 ++++++++--- tests/foreman/virtwho/ui/test_esx.py | 18 +++++++++++++----- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/robottelo/utils/virtwho.py b/robottelo/utils/virtwho.py index 2f176d55341..5e0f3a4657a 100644 --- a/robottelo/utils/virtwho.py +++ b/robottelo/utils/virtwho.py @@ -506,7 +506,7 @@ def virtwho_package_locked(): assert "Packages are locked" in result[1] -def create_http_proxy(org, name=None, url=None, http_type='https'): +def create_http_proxy(org, location, name=None, url=None, http_type='https'): """ Creat a new http-proxy with attributes. :param name: Name of the proxy @@ -524,6 +524,7 @@ def create_http_proxy(org, name=None, url=None, http_type='https'): name=http_proxy_name, url=http_proxy_url, organization=[org.id], + location=[location.id], ).create() return http_proxy.url, http_proxy.name, http_proxy.id diff --git a/tests/foreman/virtwho/api/test_esx.py b/tests/foreman/virtwho/api/test_esx.py index cdea45e72b4..bb6046188a0 100644 --- a/tests/foreman/virtwho/api/test_esx.py +++ b/tests/foreman/virtwho/api/test_esx.py @@ -210,7 +210,7 @@ def test_positive_filter_option( @pytest.mark.tier2 def test_positive_proxy_option( - self, default_org, form_data_api, virtwho_config_api, target_sat + self, default_org, default_location, form_data_api, virtwho_config_api, target_sat ): """Verify http_proxy option by "PUT @@ -232,7 +232,7 @@ def test_positive_proxy_option( assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == '*' # Check HTTTP Proxy and No_PROXY option http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy( - http_type='http', org=default_org + http_type='http', org=default_org, location=default_location ) no_proxy = 'test.satellite.com' virtwho_config_api.http_proxy_id = http_proxy_id @@ -245,7 +245,9 @@ def test_positive_proxy_option( assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy_url assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy # Check HTTTPs Proxy option - https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy(org=default_org) + https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy( + org=default_org, location=default_location + ) virtwho_config_api.http_proxy_id = https_proxy_id virtwho_config_api.update(['http_proxy_id']) deploy_configure_by_command( diff --git a/tests/foreman/virtwho/api/test_esx_sca.py b/tests/foreman/virtwho/api/test_esx_sca.py index 290e67242f5..2d43f59637a 100644 --- a/tests/foreman/virtwho/api/test_esx_sca.py +++ b/tests/foreman/virtwho/api/test_esx_sca.py @@ -227,7 +227,9 @@ def test_positive_filter_option( assert result.exclude_host_parents == regex @pytest.mark.tier2 - def test_positive_proxy_option(self, module_sca_manifest_org, form_data_api, target_sat): + def test_positive_proxy_option( + self, module_sca_manifest_org, default_location, form_data_api, target_sat + ): """Verify http_proxy option by "PUT /foreman_virt_who_configure/api/v2/configs/:id"" @@ -251,7 +253,7 @@ def test_positive_proxy_option(self, module_sca_manifest_org, form_data_api, tar assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == '*' # Check HTTTP Proxy and No_PROXY option http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy( - http_type='http', org=module_sca_manifest_org + http_type='http', org=module_sca_manifest_org, location=default_location ) no_proxy = 'test.satellite.com' virtwho_config.http_proxy_id = http_proxy_id @@ -269,7 +271,7 @@ def test_positive_proxy_option(self, module_sca_manifest_org, form_data_api, tar assert result.no_proxy == no_proxy # Check HTTTPs Proxy option https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy( - org=module_sca_manifest_org + org=module_sca_manifest_org, location=default_location ) virtwho_config.http_proxy_id = https_proxy_id virtwho_config.update(['http_proxy_id']) diff --git a/tests/foreman/virtwho/cli/test_esx.py b/tests/foreman/virtwho/cli/test_esx.py index c661d31cd67..c18ffb3ab30 100644 --- a/tests/foreman/virtwho/cli/test_esx.py +++ b/tests/foreman/virtwho/cli/test_esx.py @@ -214,7 +214,7 @@ def test_positive_filter_option( @pytest.mark.tier2 def test_positive_proxy_option( - self, default_org, form_data_cli, virtwho_config_cli, target_sat + self, default_org, default_location, form_data_cli, virtwho_config_cli, target_sat ): """Verify http_proxy option by hammer virt-who-config update" @@ -227,7 +227,9 @@ def test_positive_proxy_option( :BZ: 1902199 """ # Check the https proxy option, update it via http proxy name - https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy(org=default_org) + https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy( + org=default_org, location=default_location + ) no_proxy = 'test.satellite.com' target_sat.cli.VirtWhoConfig.update( {'id': virtwho_config_cli['id'], 'http-proxy': https_proxy_name, 'no-proxy': no_proxy} @@ -244,7 +246,7 @@ def test_positive_proxy_option( # Check the http proxy option, update it via http proxy id http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy( - http_type='http', org=default_org + http_type='http', org=default_org, location=default_location ) target_sat.cli.VirtWhoConfig.update( {'id': virtwho_config_cli['id'], 'http-proxy-id': http_proxy_id} diff --git a/tests/foreman/virtwho/cli/test_esx_sca.py b/tests/foreman/virtwho/cli/test_esx_sca.py index 7c5a4f5bc20..6b15b6803f9 100644 --- a/tests/foreman/virtwho/cli/test_esx_sca.py +++ b/tests/foreman/virtwho/cli/test_esx_sca.py @@ -250,7 +250,12 @@ def test_positive_filter_option( @pytest.mark.tier2 def test_positive_proxy_option( - self, module_sca_manifest_org, form_data_cli, virtwho_config_cli, target_sat + self, + module_sca_manifest_org, + default_location, + form_data_cli, + virtwho_config_cli, + target_sat, ): """Verify http_proxy option by hammer virt-who-config update" @@ -266,7 +271,7 @@ def test_positive_proxy_option( """ # Check the https proxy option, update it via http proxy name https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy( - org=module_sca_manifest_org + org=module_sca_manifest_org, location=default_location ) no_proxy = 'test.satellite.com' target_sat.cli.VirtWhoConfig.update( @@ -284,7 +289,7 @@ def test_positive_proxy_option( # Check the http proxy option, update it via http proxy id http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy( - http_type='http', org=module_sca_manifest_org + http_type='http', org=module_sca_manifest_org, location=default_location ) target_sat.cli.VirtWhoConfig.update( {'id': virtwho_config_cli['id'], 'http-proxy-id': http_proxy_id} diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index b81536ab211..efd46e6deba 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -215,7 +215,9 @@ def test_positive_filtering_option( assert regex == get_configure_option('exclude_host_parents', config_file) @pytest.mark.tier2 - def test_positive_proxy_option(self, default_org, virtwho_config_ui, org_session, form_data_ui): + def test_positive_proxy_option( + self, default_org, default_location, virtwho_config_ui, org_session, form_data_ui + ): """Verify 'HTTP Proxy' and 'Ignore Proxy' options. :id: 6659d577-0135-4bf0-81af-14b930011536 @@ -225,9 +227,11 @@ def test_positive_proxy_option(self, default_org, virtwho_config_ui, org_session :CaseImportance: Medium """ - https_proxy, https_proxy_name, https_proxy_id = create_http_proxy(org=default_org) + https_proxy, https_proxy_name, https_proxy_id = create_http_proxy( + org=default_org, location=default_location + ) http_proxy, http_proxy_name, http_proxy_id = create_http_proxy( - http_type='http', org=default_org + http_type='http', org=default_org, location=default_location ) name = form_data_ui['name'] config_id = get_configure_id(name) @@ -547,7 +551,9 @@ def test_positive_virtwho_manager_role( assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_overview_label_name(self, default_org, form_data_ui, org_session): + def test_positive_overview_label_name( + self, default_org, default_location, form_data_ui, org_session + ): """Verify the label name on virt-who config Overview Page. :id: 21df8175-bb41-422e-a263-8677bc3a9565 @@ -561,7 +567,9 @@ def test_positive_overview_label_name(self, default_org, form_data_ui, org_sessi name = gen_string('alpha') form_data_ui['name'] = name hypervisor_type = form_data_ui['hypervisor_type'] - http_proxy_url, proxy_name, proxy_id = create_http_proxy(org=default_org) + http_proxy_url, proxy_name, proxy_id = create_http_proxy( + org=default_org, location=default_location + ) form_data_ui['proxy'] = http_proxy_url form_data_ui['no_proxy'] = 'test.satellite.com' regex = '.*redhat.com'