Skip to content

Commit

Permalink
http proxy create location option support (SatelliteQE#13768)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanpliu authored and shweta83 committed Apr 10, 2024
1 parent 9ae1f1d commit d81af43
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
3 changes: 2 additions & 1 deletion robottelo/utils/virtwho.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 5 additions & 3 deletions tests/foreman/virtwho/api/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions tests/foreman/virtwho/api/test_esx_sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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""
Expand All @@ -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
Expand All @@ -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'])
Expand Down
8 changes: 5 additions & 3 deletions tests/foreman/virtwho/cli/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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}
Expand All @@ -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}
Expand Down
11 changes: 8 additions & 3 deletions tests/foreman/virtwho/cli/test_esx_sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(
Expand All @@ -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}
Expand Down
18 changes: 13 additions & 5 deletions tests/foreman/virtwho/ui/test_esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit d81af43

Please sign in to comment.