Skip to content

Commit de7a385

Browse files
Add test coverage for SAT-28860 (#17153)
* Add test coverage for SAT-28860 Signed-off-by: Gaurav Talreja <gtalreja@redhat.com> * Update default proxy parameter to content_default_http_proxy Signed-off-by: Gaurav Talreja <gtalreja@redhat.com> --------- Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
1 parent 699685c commit de7a385

File tree

3 files changed

+79
-11
lines changed

3 files changed

+79
-11
lines changed

pytest_fixtures/component/http_proxy.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,30 @@ def session_auth_proxy(session_target_sat):
1313
@pytest.fixture
1414
def setup_http_proxy(request, module_manifest_org, target_sat):
1515
"""Create a new HTTP proxy and set related settings based on proxy"""
16+
content_proxy = target_sat.api.Setting().search(
17+
query={'search': 'name=content_default_http_proxy'}
18+
)[0]
19+
content_proxy_value = '' if content_proxy.value is None else content_proxy.value
20+
general_proxy = target_sat.api.Setting().search(query={'search': 'name=http_proxy'})[0]
21+
general_proxy_value = '' if general_proxy.value is None else general_proxy.value
22+
1623
http_proxy = target_sat.api_factory.make_http_proxy(module_manifest_org, request.param)
17-
general_proxy = http_proxy.url if request.param is False else ''
18-
if request.param:
24+
content_proxy = target_sat.api.Setting().search(
25+
query={'search': 'name=content_default_http_proxy'}
26+
)[0]
27+
assert content_proxy.value == (http_proxy.name if request.param is not None else '')
28+
29+
if request.param is not None:
1930
general_proxy = (
20-
f'http://{settings.http_proxy.username}:'
21-
f'{settings.http_proxy.password}@{http_proxy.url[7:]}'
31+
f'http://{settings.http_proxy.username}:{settings.http_proxy.password}@{http_proxy.url[7:]}'
32+
if request.param
33+
else http_proxy.url
2234
)
23-
content_proxy_value = target_sat.update_setting(
24-
'content_default_http_proxy', http_proxy.name if request.param is not None else ''
25-
)
26-
general_proxy_value = target_sat.update_setting(
27-
'http_proxy', general_proxy if request.param is not None else ''
28-
)
35+
target_sat.update_setting('http_proxy', general_proxy)
36+
else:
37+
target_sat.update_setting('content_default_http_proxy', '')
38+
target_sat.update_setting('http_proxy', '')
39+
2940
yield http_proxy, request.param
3041
target_sat.update_setting('content_default_http_proxy', content_proxy_value)
3142
target_sat.update_setting('http_proxy', general_proxy_value)

robottelo/host_helpers/api_factory.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def make_http_proxy(self, org, http_proxy_type):
3939
name=gen_string('alpha', 15),
4040
url=settings.http_proxy.un_auth_proxy_url,
4141
organization=[org.id],
42+
content_default_http_proxy=True,
4243
).create()
4344
if http_proxy_type:
4445
return self._satellite.api.HTTPProxy(
@@ -47,6 +48,7 @@ def make_http_proxy(self, org, http_proxy_type):
4748
username=settings.http_proxy.username,
4849
password=settings.http_proxy.password,
4950
organization=[org.id],
51+
content_default_http_proxy=True,
5052
).create()
5153
return None
5254

tests/foreman/ui/test_http_proxy.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def test_positive_assign_http_proxy_to_products_repositories(
201201
@pytest.mark.tier1
202202
@pytest.mark.run_in_one_thread
203203
@pytest.mark.parametrize('setting_update', ['content_default_http_proxy'], indirect=True)
204-
def test_set_default_http_proxy(module_org, module_location, setting_update, target_sat):
204+
def test_set_default_http_proxy_no_global_default(
205+
module_org, module_location, setting_update, target_sat
206+
):
205207
"""Setting "Default HTTP proxy" to "no global default".
206208
207209
:id: e93733e1-5c05-4b7f-89e4-253b9ce55a5a
@@ -244,6 +246,59 @@ def test_set_default_http_proxy(module_org, module_location, setting_update, tar
244246
assert result['table'][0]['Value'] == "Empty"
245247

246248

249+
@pytest.mark.tier1
250+
@pytest.mark.run_in_one_thread
251+
@pytest.mark.parametrize('setting_update', ['content_default_http_proxy'], indirect=True)
252+
def test_positive_set_default_http_proxy(
253+
request, module_org, module_location, setting_update, target_sat
254+
):
255+
"""Setting "Default HTTP proxy" when new HTTP proxy is created.
256+
257+
:id: e93733e1-5c05-4b7f-89e4-253b9ce55a5b
258+
259+
:steps:
260+
1. Navigate to Infrastructure > Http Proxies
261+
2. Create a Http Proxy and set "Default content HTTP proxy"
262+
3. Navigate to Administer > Settings > Content tab
263+
4. Verify the "Default HTTP Proxy" setting with created above.
264+
5. Update "Default HTTP Proxy" to "no global default".
265+
266+
:Verifies: SAT-28860
267+
268+
:expectedresults: Creating Http Proxy with option "Default content HTTP proxy",
269+
updates setting "Default HTTP Proxy" succesfully.
270+
"""
271+
property_name = setting_update.name
272+
http_proxy_name = gen_string('alpha', 15)
273+
http_proxy_url = settings.http_proxy.un_auth_proxy_url
274+
275+
with target_sat.ui_session() as session:
276+
session.http_proxy.create(
277+
{
278+
'http_proxy.name': http_proxy_name,
279+
'http_proxy.url': http_proxy_url,
280+
'http_proxy.content_default_http_proxy': 'true',
281+
'locations.resources.assigned': [module_location.name],
282+
'organizations.resources.assigned': [module_org.name],
283+
}
284+
)
285+
286+
# Teardown
287+
@request.addfinalizer
288+
def _finalize():
289+
target_sat.api.HTTPProxy().search(query={'search': f'name={http_proxy_name}'})[
290+
0
291+
].delete()
292+
default_proxy = target_sat.api.Setting().search(
293+
query={'search': 'name=content_default_http_proxy'}
294+
)[0]
295+
assert default_proxy.value != http_proxy_name
296+
assert not default_proxy.value
297+
298+
result = session.settings.read(f'name = {property_name}')
299+
assert result['table'][0]['Value'] == f'{http_proxy_name} ({http_proxy_url})'
300+
301+
247302
@pytest.mark.tier1
248303
@pytest.mark.run_in_one_thread
249304
@pytest.mark.parametrize('setting_update', ['content_default_http_proxy'], indirect=True)

0 commit comments

Comments
 (0)