Skip to content

Commit dc1fc11

Browse files
authored
Merge branch '6.19.z' into cherry-pick-6.19.z-b63db29008c99e58249bccc22cd2b912c3d356a5
2 parents f8a15e2 + 5e8b554 commit dc1fc11

14 files changed

Lines changed: 182 additions & 40 deletions

conf/container.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CONTAINER:
44
- docker
55
- podman
66
REGISTRY_HUB: https://mirror.gcr.io
7-
UPSTREAM_NAME: 'library/busybox'
7+
UPSTREAM_NAME: jmalloc/echo-server
88
ALTERNATIVE_UPSTREAM_NAMES:
99
- hello-world
1010
- alpine

pytest_fixtures/component/hostgroup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ def module_hostgroup(module_target_sat):
1010
return module_target_sat.api.HostGroup().create()
1111

1212

13+
@pytest.fixture(scope='module')
14+
def module_hostgroup_with_org_loc(module_target_sat, module_org, module_location):
15+
return module_target_sat.api.HostGroup(
16+
organization=[module_org], location=[module_location]
17+
).create()
18+
19+
1320
@pytest.fixture(scope='class')
1421
def class_hostgroup(class_target_sat, class_org, class_location):
1522
"""Create a hostgroup linked to specific org and location created at the class scope"""

pytest_fixtures/component/taxonomy.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ def sca_manifest_for_upgrade():
226226

227227

228228
@pytest.fixture
229-
def func_future_dated_subscription_manifest(target_sat, function_org):
230-
"""Create and upload future date subscription manifest into org"""
229+
def func_future_dated_subscription_manifest():
230+
"""Returns future dated manifest. Used only for future date subscription scenarios."""
231231
with Manifester(manifest_category=settings.manifest.future_date_subscription) as manifest:
232-
target_sat.upload_manifest(function_org.id, manifest.content)
233-
return manifest
232+
yield manifest

pytest_fixtures/component/user_role.py

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
1-
from fauxfactory import gen_alphanumeric, gen_string
1+
from fauxfactory import gen_alphanumeric
22
import pytest
33

44

5+
class UserFactory:
6+
"""Helper class for more complex operations with users that can be reused in fixtures."""
7+
8+
@staticmethod
9+
def create_user(target_sat, **params):
10+
"""Create and return a user object. Set the password if not specified.
11+
Args:
12+
target_sat: Satellite object
13+
params: parameters passed to the User object
14+
Returns:
15+
User object
16+
"""
17+
params.setdefault('password', gen_alphanumeric())
18+
user = target_sat.api.User(**params).create()
19+
user.password = params['password']
20+
return user
21+
22+
23+
@pytest.fixture(scope='session')
24+
def viewer_role(session_target_sat):
25+
"""Viewer role."""
26+
return session_target_sat.api.Role().search(query={'search': 'name="Viewer"'})[0]
27+
28+
529
@pytest.fixture(scope='class')
630
def class_user_password():
731
"""Generate a random password for a user, and capture it so a test has access to it"""
@@ -26,19 +50,27 @@ def module_user(module_target_sat, module_org, module_location):
2650

2751

2852
@pytest.fixture(scope='module')
29-
def default_viewer_role(module_target_sat, module_org, default_location):
53+
def default_viewer_role(module_target_sat, module_org, default_location, viewer_role):
3054
"""Custom user with viewer role for tests validating visibility of entities or fields created
3155
by some other user. Created only when accessed, unlike `module_user`.
3256
"""
33-
viewer_role = module_target_sat.api.Role().search(query={'search': 'name="Viewer"'})[0]
34-
custom_password = gen_string('alphanumeric')
35-
custom_user = module_target_sat.api.User(
57+
return UserFactory.create_user(
58+
target_sat=module_target_sat,
3659
admin=False,
3760
default_organization=module_org,
3861
location=[default_location],
3962
organization=[module_org],
4063
role=[viewer_role],
41-
password=custom_password,
42-
).create()
43-
custom_user.password = custom_password
44-
return custom_user
64+
)
65+
66+
67+
@pytest.fixture(scope='module')
68+
def module_user_viewer(module_target_sat, module_org, module_location, viewer_role):
69+
"""Non-admin user with Viewer role."""
70+
return UserFactory.create_user(
71+
target_sat=module_target_sat,
72+
admin=False,
73+
location=[module_location],
74+
organization=[module_org],
75+
role=[viewer_role],
76+
)

requirements-optional.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# For running tests and checking code quality using these modules.
22
pytest-cov==7.0.0
3-
redis==7.2.0
3+
redis==7.2.1
44
pre-commit==4.5.1
55
ruff==0.15.2
66

robottelo/config/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
'container.upstream_name',
120120
must_exist=True,
121121
is_type_of=str,
122-
default='library/busybox',
122+
default='jmalloc/echo-server',
123123
),
124124
Validator(
125125
'container.alternative_upstream_names',

robottelo/content_info.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ def get_repo_files_by_url(url, extension='rpm'):
6969
return sorted([os.path.basename(f) for f in get_repo_files_urls_by_url(url, extension)])
7070

7171

72+
def get_baseurl_by_repofile(repo_url, verify_ssl=True):
73+
"""
74+
Returns the baseurl from a remote yum .repo file.
75+
76+
:param repo_url: URL to the .repo file
77+
:return: baseurl string
78+
:raises requests.HTTPError: if URL not accessible
79+
:raises ValueError: if baseurl not found
80+
"""
81+
response = requests.get(repo_url, verify=verify_ssl, timeout=10)
82+
response.raise_for_status()
83+
84+
for line in response.text.splitlines():
85+
line = line.strip()
86+
87+
if line.startswith('baseurl='):
88+
return line.split('=', 1)[1].strip()
89+
90+
raise ValueError(f'No baseurl found in {repo_url}')
91+
92+
7293
def get_repomd(repo_url):
7394
"""Fetches content of the repomd file of a repository
7495

tests/foreman/api/test_convert2rhel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from robottelo.config import settings
2121
from robottelo.constants import DEFAULT_ARCHITECTURE, REPOS
22+
from robottelo.content_info import get_baseurl_by_repofile
2223
from robottelo.utils.issue_handlers import is_open
2324

2425

@@ -134,7 +135,8 @@ def centos(
134135

135136
centos_host.enable_ipv6_dnf_proxy()
136137
assert centos_host.execute('yum -y update').status == 0
137-
repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major)
138+
repofile_url = settings.repos.convert2rhel.convert_to_rhel_repofile.format(major)
139+
repo_url = get_baseurl_by_repofile(repofile_url)
138140
repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url)
139141
cv = update_cv(
140142
module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]
@@ -229,7 +231,8 @@ def oracle(
229231
if oracle_host.execute('needs-restarting -r').status == 1:
230232
oracle_host.power_control(state='reboot')
231233

232-
repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major)
234+
repofile_url = settings.repos.convert2rhel.convert_to_rhel_repofile.format(major)
235+
repo_url = get_baseurl_by_repofile(repofile_url)
233236
repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url, ssl_cert)
234237
cv = update_cv(
235238
module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]

tests/foreman/cli/test_container_management.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
from datetime import UTC, datetime
14+
import re
1415

1516
from box import Box
1617
from fauxfactory import gen_string
@@ -94,16 +95,18 @@ def test_positive_pull_image(
9495
)
9596
assert result.status == 0
9697
try:
97-
result = module_container_contenthost.execute(f'docker run {repo["published-at"]}')
98+
result = module_container_contenthost.execute(
99+
f'docker run -d {repo["published-at"]}'
100+
)
98101
assert result.status == 0
102+
match = re.match(r'^[0-9a-f]+$', result.stdout)
103+
if match:
104+
container_id = match.group(0)
99105
finally:
100106
# Stop and remove the container
101-
result = module_container_contenthost.execute(
102-
f'docker ps -a | grep {repo["published-at"]}'
103-
)
104-
container_id = result.stdout[0].split()[0]
105-
module_container_contenthost.execute(f'docker stop {container_id}')
106-
module_container_contenthost.execute(f'docker rm {container_id}')
107+
if container_id:
108+
module_container_contenthost.execute(f'docker stop {container_id}')
109+
module_container_contenthost.execute(f'docker rm {container_id}')
107110
finally:
108111
# Remove docker image
109112
module_container_contenthost.execute(f'docker rmi {repo["published-at"]}')

tests/foreman/destructive/test_ldap_authentication.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,8 @@ def test_single_sign_on_ldap_ad_server(
266266
assert f'{url}/new/hosts' in result.stdout
267267

268268

269-
@pytest.mark.parametrize(
270-
'setting_update',
271-
[f'login_delegation_logout_url={LOGIN_DELEGATION_LOGOUT_URL}'],
272-
ids=["external_redirect"],
273-
indirect=True,
274-
)
275269
def test_single_sign_on_using_rhsso(
276-
enable_external_auth_rhsso, rhsso_setting_setup, module_target_sat, setting_update
270+
enable_external_auth_rhsso, rhsso_setting_setup, module_target_sat
277271
):
278272
"""Verify the single sign-on functionality with external authentication RH-SSO
279273
@@ -299,11 +293,23 @@ def test_single_sign_on_using_rhsso(
299293
actual_user = session.task.read_all(widget_names="current_user")['current_user']
300294
assert settings.rhsso.rhsso_user in actual_user
301295
# logout verification for SAT-40322
302-
session.rhsso_login.logout()
303-
assert session.browser.url == LOGIN_DELEGATION_LOGOUT_URL, "Unsuccessful logout redirect"
304-
with pytest.raises(NavigationTriesExceeded) as error:
305-
session.task.read_all(widget_names='current_user')['current_user']
306-
assert error.typename == 'NavigationTriesExceeded'
296+
setting_object = module_target_sat.api.Setting().search(
297+
query={'search': 'name=login_delegation_logout_url'}
298+
)[0]
299+
default_setting_value = '' if setting_object.value is None else setting_object.value
300+
setting_object.value = LOGIN_DELEGATION_LOGOUT_URL
301+
setting_object.update({'value'})
302+
try:
303+
session.rhsso_login.logout()
304+
assert session.browser.url == LOGIN_DELEGATION_LOGOUT_URL, (
305+
"Unsuccessful logout redirect"
306+
)
307+
with pytest.raises(NavigationTriesExceeded) as error:
308+
session.task.read_all(widget_names='current_user')['current_user']
309+
assert error.typename == 'NavigationTriesExceeded'
310+
finally:
311+
setting_object.value = default_setting_value
312+
setting_object.update({'value'})
307313

308314

309315
def test_external_logout_rhsso(rhsso_setting_setup, enable_external_auth_rhsso, module_target_sat):

0 commit comments

Comments
 (0)