mirror of
https://github.com/containers/podman-compose.git
synced 2024-10-05 01:22:10 +02:00
Merge pull request #946 from charliemirabile/selinux_tests
Missing SELinux tests
This commit is contained in:
commit
cac90f69b8
@ -4,6 +4,8 @@ import unittest
|
|||||||
from os import path
|
from os import path
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
from parameterized import parameterized
|
||||||
|
|
||||||
from podman_compose import container_to_args
|
from podman_compose import container_to_args
|
||||||
|
|
||||||
|
|
||||||
@ -463,3 +465,43 @@ class TestContainerToArgs(unittest.IsolatedAsyncioTestCase):
|
|||||||
"nvidia-smi",
|
"nvidia-smi",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@parameterized.expand([
|
||||||
|
(False, "z", ["--mount", "type=bind,source=./foo,destination=/mnt,z"]),
|
||||||
|
(False, "Z", ["--mount", "type=bind,source=./foo,destination=/mnt,Z"]),
|
||||||
|
(True, "z", ["-v", "./foo:/mnt:z"]),
|
||||||
|
(True, "Z", ["-v", "./foo:/mnt:Z"]),
|
||||||
|
])
|
||||||
|
async def test_selinux_volume(self, prefer_volume, selinux_type, expected_additional_args):
|
||||||
|
c = create_compose_mock()
|
||||||
|
c.prefer_volume_over_mount = prefer_volume
|
||||||
|
|
||||||
|
cnt = get_minimal_container()
|
||||||
|
|
||||||
|
# This is supposed to happen during `_parse_compose_file`
|
||||||
|
# but that is probably getting skipped during testing
|
||||||
|
cnt["_service"] = cnt["service_name"]
|
||||||
|
|
||||||
|
cnt["volumes"] = [
|
||||||
|
{
|
||||||
|
"type": "bind",
|
||||||
|
"source": "./foo",
|
||||||
|
"target": "/mnt",
|
||||||
|
"bind": {
|
||||||
|
"selinux": selinux_type,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
args = await container_to_args(c, cnt)
|
||||||
|
self.assertEqual(
|
||||||
|
args,
|
||||||
|
[
|
||||||
|
"--name=project_name_service_name1",
|
||||||
|
"-d",
|
||||||
|
*expected_additional_args,
|
||||||
|
"--network=bridge",
|
||||||
|
"--network-alias=service_name",
|
||||||
|
"busybox",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user