|
| 1 | +From 0fa4c10ee454ec478b7029f7a0d4dce81e88e4ec Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ricardo Branco < [email protected]> |
| 3 | +Date: Sat, 18 Oct 2025 21:04:04 +0200 |
| 4 | +Subject: [PATCH] tests/integration: Make the tests runnable on SELinux enabled |
| 5 | + daemon |
| 6 | + |
| 7 | +Signed-off-by: Ricardo Branco < [email protected]> |
| 8 | +--- |
| 9 | + tests/integration/api_container_test.py | 21 ++++++++++++++++----- |
| 10 | + tests/integration/models_containers_test.py | 4 ++-- |
| 11 | + 2 files changed, 18 insertions(+), 7 deletions(-) |
| 12 | + |
| 13 | +diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py |
| 14 | +index 21c2f35797..e780a3f3d4 100644 |
| 15 | +--- a/tests/integration/api_container_test.py |
| 16 | ++++ b/tests/integration/api_container_test.py |
| 17 | +@@ -570,7 +570,10 @@ def test_create_with_mounts(self): |
| 18 | + mount = docker.types.Mount( |
| 19 | + type="bind", source=self.mount_origin, target=self.mount_dest |
| 20 | + ) |
| 21 | +- host_config = self.client.create_host_config(mounts=[mount]) |
| 22 | ++ host_config = self.client.create_host_config( |
| 23 | ++ mounts=[mount], |
| 24 | ++ security_opt=["label=disable"], |
| 25 | ++ ) |
| 26 | + container = self.run_container( |
| 27 | + TEST_IMG, ['ls', self.mount_dest], |
| 28 | + host_config=host_config |
| 29 | +@@ -587,7 +590,10 @@ def test_create_with_mounts_ro(self): |
| 30 | + type="bind", source=self.mount_origin, target=self.mount_dest, |
| 31 | + read_only=True |
| 32 | + ) |
| 33 | +- host_config = self.client.create_host_config(mounts=[mount]) |
| 34 | ++ host_config = self.client.create_host_config( |
| 35 | ++ mounts=[mount], |
| 36 | ++ security_opt=["label=disable"], |
| 37 | ++ ) |
| 38 | + container = self.run_container( |
| 39 | + TEST_IMG, ['ls', self.mount_dest], |
| 40 | + host_config=host_config |
| 41 | +@@ -604,7 +610,10 @@ def test_create_with_volume_mount(self): |
| 42 | + type="volume", source=helpers.random_name(), |
| 43 | + target=self.mount_dest, labels={'com.dockerpy.test': 'true'} |
| 44 | + ) |
| 45 | +- host_config = self.client.create_host_config(mounts=[mount]) |
| 46 | ++ host_config = self.client.create_host_config( |
| 47 | ++ mounts=[mount], |
| 48 | ++ security_opt=["label=disable"], |
| 49 | ++ ) |
| 50 | + container = self.client.create_container( |
| 51 | + TEST_IMG, ['true'], host_config=host_config, |
| 52 | + ) |
| 53 | +@@ -693,7 +702,8 @@ def run_with_volume(self, ro, *args, **kwargs): |
| 54 | + 'ro': ro, |
| 55 | + }, |
| 56 | + }, |
| 57 | +- network_mode='none' |
| 58 | ++ network_mode='none', |
| 59 | ++ security_opt=["label=disable"], |
| 60 | + ), |
| 61 | + **kwargs |
| 62 | + ) |
| 63 | +@@ -710,7 +720,8 @@ def run_with_volume_propagation(self, ro, propagation, *args, **kwargs): |
| 64 | + 'propagation': propagation |
| 65 | + }, |
| 66 | + }, |
| 67 | +- network_mode='none' |
| 68 | ++ network_mode='none', |
| 69 | ++ security_opt=["label=disable"], |
| 70 | + ), |
| 71 | + **kwargs |
| 72 | + ) |
| 73 | +diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py |
| 74 | +index 8727455932..0dc5a43828 100644 |
| 75 | +--- a/tests/integration/models_containers_test.py |
| 76 | ++++ b/tests/integration/models_containers_test.py |
| 77 | +@@ -48,7 +48,7 @@ def test_run_with_volume(self): |
| 78 | + |
| 79 | + container = client.containers.run( |
| 80 | + "alpine", "sh -c 'echo \"hello\" > /insidecontainer/test'", |
| 81 | +- volumes=[f"{path}:/insidecontainer"], |
| 82 | ++ volumes=[f"{path}:/insidecontainer:z"], |
| 83 | + detach=True |
| 84 | + ) |
| 85 | + self.tmp_containers.append(container.id) |
| 86 | +@@ -57,7 +57,7 @@ def test_run_with_volume(self): |
| 87 | + name = "container_volume_test" |
| 88 | + out = client.containers.run( |
| 89 | + "alpine", "cat /insidecontainer/test", |
| 90 | +- volumes=[f"{path}:/insidecontainer"], |
| 91 | ++ volumes=[f"{path}:/insidecontainer:z"], |
| 92 | + name=name |
| 93 | + ) |
| 94 | + self.tmp_containers.append(name) |
0 commit comments