Skip to content

Commit

Permalink
Check for BCI and BETA EULA to be in place
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Čermák <[email protected]>
  • Loading branch information
dirkmueller and dcermak committed Sep 16, 2024
1 parent c143145 commit 2683ee1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bci_tester/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
# Test base containers by default for these versions
_DEFAULT_BASE_OS_VERSIONS = ("15.5", "15.6", "15.7", "tumbleweed")

# List the released versions of SLE, used for supportabilty and EULA tests
RELEASED_SLE_VERSIONS = ("15.3", "15.4", "15.5", "15.6")

assert (
sorted(ALLOWED_BASE_OS_VERSIONS) == list(ALLOWED_BASE_OS_VERSIONS)
), f"list ALLOWED_BASE_OS_VERSIONS must be sorted, but got {ALLOWED_BASE_OS_VERSIONS}"
Expand Down
60 changes: 60 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from bci_tester.data import ALLOWED_BCI_REPO_OS_VERSIONS
from bci_tester.data import ALL_CONTAINERS
from bci_tester.data import BASE_CONTAINER
from bci_tester.data import BCI_DEVEL_REPO
from bci_tester.data import BCI_REPO_NAME
from bci_tester.data import BUSYBOX_CONTAINER
Expand All @@ -30,10 +31,13 @@
from bci_tester.data import DISTRIBUTION_CONTAINER
from bci_tester.data import INIT_CONTAINER
from bci_tester.data import KIWI_CONTAINERS
from bci_tester.data import MICRO_CONTAINER
from bci_tester.data import MINIMAL_CONTAINER
from bci_tester.data import OS_PRETTY_NAME
from bci_tester.data import OS_VERSION
from bci_tester.data import OS_VERSION_ID
from bci_tester.data import PCP_CONTAINERS
from bci_tester.data import RELEASED_SLE_VERSIONS
from bci_tester.util import get_repos_from_connection

CONTAINER_IMAGES = ALL_CONTAINERS
Expand Down Expand Up @@ -421,6 +425,62 @@ def test_no_compat_packages(container):
).is_installed


@pytest.mark.parametrize(
"container",
ALL_CONTAINERS,
indirect=True,
)
def test_bci_eula_is_correctly_available(container: ContainerData) -> None:
"""Ensure that the BCI eula exists iff it's not a LTSS container"""

bci_license = "/usr/share/licenses/product/BCI/license.txt"
if (
OS_VERSION in ALLOWED_BCI_REPO_OS_VERSIONS
and OS_VERSION in RELEASED_SLE_VERSIONS
):
assert container.connection.file(bci_license).exists
assert (
"SUSE Linux Enterprise Base Container Image License"
in container.connection.check_output(f"head -n 1 {bci_license}")
)
return

# LTSS containers should not have the BCI license, however we currently
# are running tests for the bci-* base os containers which are not LTSS
# and still contain a BCI license. As they are out of maintenance, we
# need to ignore them
if OS_VERSION in RELEASED_SLE_VERSIONS and container.container in (
BASE_CONTAINER.values[0],
INIT_CONTAINER.values[0],
MINIMAL_CONTAINER.values[0],
MICRO_CONTAINER.values[0],
):
pytest.skip("Unmaintained bci-* base os containers are not tested")
return
assert not container.connection.file(bci_license).exists


@pytest.mark.skipif(
OS_VERSION in RELEASED_SLE_VERSIONS
or OS_VERSION in ("basalt", "tumbleweed"),
reason="BETA EULA not expected",
)
@pytest.mark.parametrize(
"container",
ALL_CONTAINERS,
indirect=True,
)
def test_sles_beta_eula_exists(container):
"""Ensure that the SLES Beta eula exists in the container"""

assert (
"SUSE(R) End User License Agreement for Beta Software"
in container.connection.check_output(
"head -n 1 /usr/share/licenses/product/base/license.txt"
)
)


@pytest.mark.parametrize("runner", ALL_CONTAINERS)
def test_certificates_are_present(
host, tmp_path, container_runtime, runner: Container, pytestconfig: Config
Expand Down

0 comments on commit 2683ee1

Please sign in to comment.