Skip to content

Commit 55a5ef2

Browse files
committed
[tests] fix the pytest tests executio on linux machine with SELinux
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.
1 parent fa13ab3 commit 55a5ef2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/containers/base_image_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TestBaseImage:
2121
"""Tests that are applicable for all images we have in this repository."""
2222

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

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

5757
try:

0 commit comments

Comments
 (0)