Skip to content

Commit

Permalink
[tests] fix the pytest tests executio on linux machine with SELinux
Browse files Browse the repository at this point in the history
There is necessary to use "z" option when mounting files into the
container otherwise SELinux will not allow container to read the mounted
file.

Also, I've adjusted the UIDs used in the tests so that they are lower
than 65k because otherwise it's not possible to run these with a
root-less podman/docker.
  • Loading branch information
jstourac committed Jan 24, 2025
1 parent 151d804 commit 4a0edf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/containers/base_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestBaseImage:
"""Tests that are applicable for all images we have in this repository."""

def test_oc_command_runs(self, image: str):
container = testcontainers.core.container.DockerContainer(image=image, user=123456, group_add=[0])
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
container.with_command("/bin/sh -c 'sleep infinity'")
try:
container.start()
Expand Down Expand Up @@ -50,8 +50,8 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
# tmpdir is by-default created with perms restricting access to user only
tmp_crypto.chmod(0o777)

container = testcontainers.core.container.DockerContainer(image=image, user=654321, group_add=[0])
container.with_volume_mapping(str(tmp_crypto), "/proc/sys")
container = testcontainers.core.container.DockerContainer(image=image, user=54321, group_add=[0])
container.with_volume_mapping(str(tmp_crypto), "/proc/sys", mode="ro,z")
container.with_command("/bin/sh -c 'sleep infinity'")

try:
Expand Down

0 comments on commit 4a0edf0

Please sign in to comment.