mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-20 10:08:14 +02:00
.github
completion
docs
examples
newsfragments
scripts
tests
integration
additional_contexts
base_image
build
build_fail
build_labels
build_secrets
build_ssh
default_net_behavior
deps
env-file-tests
env-tests
exit-from
extends
extends_w_empty_service
extends_w_file
extends_w_file_subdir
filesystem
in_pod
include
interpolation
ipam_default
lifetime
multicompose
nethost
nets_test1
nets_test2
nets_test3
nets_test_ip
network
network_interface_name
network_scoped_aliases
no_services
pid
pod_args
ports
profile
seccomp
secrets
selinux
docker-compose.yml
host_test_text.txt
test_podman_compose_selinux.py
short
testlogs
uidmaps
ulimit
ulimit_build
vol
volumes_merge
yamlmagic
__init__.py
test_utils.py
unit
.codespellignore
.codespellrc
.coveragerc
.editorconfig
.gitignore
.pre-commit-config.yaml
.pylintrc
CODE-OF-CONDUCT.md
CONTRIBUTING.md
Dockerfile
LICENSE
README.md
RELEASING.md
SECURITY.md
podman_compose.py
pyproject.toml
requirements.txt
setup.cfg
setup.py
test-requirements.txt
59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import unittest
|
|
|
|
from tests.integration.test_utils import RunSubprocessMixin
|
|
from tests.integration.test_utils import podman_compose_path
|
|
from tests.integration.test_utils import test_path
|
|
|
|
|
|
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
|
def test_selinux(self):
|
|
# test if when using volumes type:bind with selinux:z option, container ackquires a
|
|
# respective host:source:z mapping in CreateCommand list
|
|
compose_path = os.path.join(test_path(), "selinux", "docker-compose.yml")
|
|
try:
|
|
# change working directory to where docker-compose.yml file is so that containers can
|
|
# directly access host source file for mounting from that working directory
|
|
subprocess.run(
|
|
[
|
|
podman_compose_path(),
|
|
"-f",
|
|
compose_path,
|
|
"up",
|
|
"-d",
|
|
"container1",
|
|
"container2",
|
|
],
|
|
cwd=os.path.join(test_path(), 'selinux'),
|
|
)
|
|
out, _ = self.run_subprocess_assert_returncode([
|
|
"podman",
|
|
"inspect",
|
|
"selinux_container1_1",
|
|
])
|
|
inspect_out = json.loads(out)
|
|
create_command_list = inspect_out[0].get("Config", []).get("CreateCommand", {})
|
|
self.assertIn('./host_test_text.txt:/test_text.txt:z', create_command_list)
|
|
|
|
out, _ = self.run_subprocess_assert_returncode([
|
|
"podman",
|
|
"inspect",
|
|
"selinux_container2_1",
|
|
])
|
|
inspect_out = json.loads(out)
|
|
create_command_list = inspect_out[0].get("Config", []).get("CreateCommand", {})
|
|
self.assertIn('./host_test_text.txt:/test_text.txt', create_command_list)
|
|
finally:
|
|
out, _ = self.run_subprocess_assert_returncode([
|
|
podman_compose_path(),
|
|
"-f",
|
|
compose_path,
|
|
"down",
|
|
"-t",
|
|
"0",
|
|
])
|