Skip to content

Commit

Permalink
[6.15.z] make oscap tests run on rhel9 backend (#14716) (#14983)
Browse files Browse the repository at this point in the history
make oscap tests run on rhel9 backend (#14716)

Co-authored-by: Ondřej Gajdušek <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 7, 2024
1 parent b66e114 commit ea33153
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
6 changes: 4 additions & 2 deletions conf/oscap.yaml.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
OSCAP:
CONTENT_PATH: /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml
RHEL_MAJOR_VERSION: "@jinja {{this.server.version.rhel_version | int }}"
CONTENT_PATH: '@format /usr/share/xml/scap/ssg/content/ssg-rhel{this.oscap.rhel_major_version}-ds.xml'
# see: robottelo/constants/__init__.py OSCAP_PROFILE
PROFILE: security7
PROFILE: '@format security{this.oscap.rhel_major_version}'
CONTENT_DIR: /usr/share/xml/scap/ssg/content
5 changes: 2 additions & 3 deletions pytest_fixtures/component/oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from robottelo.config import robottelo_tmp_dir, settings
from robottelo.constants import OSCAP_PROFILE, OSCAP_TAILORING_FILE, DataFile
from robottelo.constants import OSCAP_TAILORING_FILE, DataFile


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -35,11 +35,10 @@ def scap_content(import_ansible_roles, module_target_sat):
)
scap_id = scap_info['id']
scap_info = entities.ScapContents(id=scap_id).read()

scap_profile_id = [
profile['id']
for profile in scap_info.scap_content_profiles
if OSCAP_PROFILE[settings.oscap.profile] in profile['title']
if module_target_sat.OSCAP['dsrhel'] in profile['title']
][0]
return {
"title": title,
Expand Down
4 changes: 3 additions & 1 deletion robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1581,14 +1581,16 @@ class Colored(Box):
'rhel6_content': 'Red Hat rhel6 default content',
'rhel7_content': 'Red Hat rhel7 default content',
'rhel8_content': 'Red Hat rhel8 default content',
'rhel9_content': 'Red Hat rhel9 default content',
'rhel_firefox': 'Red Hat firefox default content',
}

OSCAP_PROFILE = {
'c2s_rhel6': 'C2S for Red Hat Enterprise Linux 6',
'dsrhel6': 'DISA STIG for Red Hat Enterprise Linux 6',
'dsrhel7': 'DISA STIG for Red Hat Enterprise Linux 7',
'dsrhel8': '[DRAFT] DISA STIG for Red Hat Enterprise Linux 8',
'dsrhel8': 'DISA STIG for Red Hat Enterprise Linux 8',
'dsrhel9': 'DISA STIG for Red Hat Enterprise Linux 9',
'esp': 'Example Server Profile',
'rhccp': 'Red Hat Corporate Profile for Certified Cloud Providers (RH CCP)',
'firefox': 'Mozilla Firefox STIG',
Expand Down
15 changes: 10 additions & 5 deletions tests/foreman/cli/test_oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def test_positive_list_default_content_with_admin(self, module_target_sat):
:CaseImportance: Medium
"""
scap_contents = [content['title'] for content in module_target_sat.cli.Scapcontent.list()]
for title in OSCAP_DEFAULT_CONTENT.values():
assert title in scap_contents
assert f'Red Hat rhel{module_target_sat.os_version.major} default content' in scap_contents

@pytest.mark.tier1
def test_negative_list_default_content_with_viewer_role(
Expand Down Expand Up @@ -296,7 +295,9 @@ def test_positive_create_scap_content_with_valid_originalfile_name(
@pytest.mark.parametrize('name', **parametrized(invalid_names_list()))
@pytest.mark.tier1
def test_negative_create_scap_content_with_invalid_originalfile_name(
self, name, module_target_sat
self,
name,
module_target_sat,
):
"""Create scap-content with invalid original file name
Expand Down Expand Up @@ -355,7 +356,10 @@ def test_negative_create_scap_content_without_dsfile(self, title, module_target_
module_target_sat.cli_factory.scapcontent({'title': title})

@pytest.mark.tier1
def test_positive_update_scap_content_with_newtitle(self, module_target_sat):
def test_positive_update_scap_content_with_newtitle(
self,
module_target_sat,
):
"""Update scap content title
:id: 2c32e94a-237d-40b9-8a3b-fca2ef26fe79
Expand Down Expand Up @@ -921,7 +925,8 @@ def test_positive_update_scap_policy_with_content(self, scap_content, module_tar
)
assert scap_policy['scap-content-id'] == scap_content["scap_id"]
scap_id, scap_profile_id = self.fetch_scap_and_profile_id(
OSCAP_DEFAULT_CONTENT['rhel_firefox'], module_target_sat
OSCAP_DEFAULT_CONTENT[f'rhel{module_target_sat.os_version.major}_content'],
module_target_sat,
)
module_target_sat.cli.Scappolicy.update(
{'name': name, 'scap-content-id': scap_id, 'scap-content-profile-id': scap_profile_id}
Expand Down
12 changes: 0 additions & 12 deletions tests/foreman/ui/test_oscapcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,12 @@
"""

import os

import pytest

from robottelo.config import robottelo_tmp_dir, settings
from robottelo.constants import DataFile
from robottelo.utils.datafactory import gen_string


@pytest.fixture(scope='module')
def oscap_content_path(module_target_sat):
_, file_name = os.path.split(settings.oscap.content_path)

local_file = robottelo_tmp_dir.joinpath(file_name)
module_target_sat.get(remote_path=settings.oscap.content_path, local_path=str(local_file))
return local_file


@pytest.mark.skip_if_open("BZ:2167937")
@pytest.mark.skip_if_open("BZ:2133151")
@pytest.mark.tier1
Expand Down

0 comments on commit ea33153

Please sign in to comment.