Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make oscap tests run on rhel9 backend #14716

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 1 addition & 2 deletions pytest_fixtures/component/oscap.py
Original file line number Diff line number Diff line change
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 @@ -1585,14 +1585,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 @@ -67,8 +67,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 @@ -295,7 +294,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 @@ -354,7 +355,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 @@ -920,7 +924,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
11 changes: 0 additions & 11 deletions tests/foreman/ui/test_oscapcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,13 @@
:CaseImportance: High
"""
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