Skip to content

Commit 0fa4c10

Browse files
tests/integration: Make the tests runnable on SELinux enabled daemon
Signed-off-by: Ricardo Branco <[email protected]>
1 parent 62bd22d commit 0fa4c10

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

tests/integration/api_container_test.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,10 @@ def test_create_with_mounts(self):
570570
mount = docker.types.Mount(
571571
type="bind", source=self.mount_origin, target=self.mount_dest
572572
)
573-
host_config = self.client.create_host_config(mounts=[mount])
573+
host_config = self.client.create_host_config(
574+
mounts=[mount],
575+
security_opt=["label=disable"],
576+
)
574577
container = self.run_container(
575578
TEST_IMG, ['ls', self.mount_dest],
576579
host_config=host_config
@@ -587,7 +590,10 @@ def test_create_with_mounts_ro(self):
587590
type="bind", source=self.mount_origin, target=self.mount_dest,
588591
read_only=True
589592
)
590-
host_config = self.client.create_host_config(mounts=[mount])
593+
host_config = self.client.create_host_config(
594+
mounts=[mount],
595+
security_opt=["label=disable"],
596+
)
591597
container = self.run_container(
592598
TEST_IMG, ['ls', self.mount_dest],
593599
host_config=host_config
@@ -604,7 +610,10 @@ def test_create_with_volume_mount(self):
604610
type="volume", source=helpers.random_name(),
605611
target=self.mount_dest, labels={'com.dockerpy.test': 'true'}
606612
)
607-
host_config = self.client.create_host_config(mounts=[mount])
613+
host_config = self.client.create_host_config(
614+
mounts=[mount],
615+
security_opt=["label=disable"],
616+
)
608617
container = self.client.create_container(
609618
TEST_IMG, ['true'], host_config=host_config,
610619
)
@@ -693,7 +702,8 @@ def run_with_volume(self, ro, *args, **kwargs):
693702
'ro': ro,
694703
},
695704
},
696-
network_mode='none'
705+
network_mode='none',
706+
security_opt=["label=disable"],
697707
),
698708
**kwargs
699709
)
@@ -710,7 +720,8 @@ def run_with_volume_propagation(self, ro, propagation, *args, **kwargs):
710720
'propagation': propagation
711721
},
712722
},
713-
network_mode='none'
723+
network_mode='none',
724+
security_opt=["label=disable"],
714725
),
715726
**kwargs
716727
)

tests/integration/models_containers_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_run_with_volume(self):
4848

4949
container = client.containers.run(
5050
"alpine", "sh -c 'echo \"hello\" > /insidecontainer/test'",
51-
volumes=[f"{path}:/insidecontainer"],
51+
volumes=[f"{path}:/insidecontainer:z"],
5252
detach=True
5353
)
5454
self.tmp_containers.append(container.id)
@@ -57,7 +57,7 @@ def test_run_with_volume(self):
5757
name = "container_volume_test"
5858
out = client.containers.run(
5959
"alpine", "cat /insidecontainer/test",
60-
volumes=[f"{path}:/insidecontainer"],
60+
volumes=[f"{path}:/insidecontainer:z"],
6161
name=name
6262
)
6363
self.tmp_containers.append(name)

0 commit comments

Comments
 (0)