Skip to content

Commit 7c61f24

Browse files
authored
Merge pull request #1158 from mokibit/automate-uidmaps-test
test/integration: Automate manual `uidmaps` test
2 parents a54f0fa + 202c377 commit 7c61f24

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

tests/integration/uidmaps/docker-compose.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ services:
66
volumes:
77
- ./:/mnt
88
user: 999:999
9-
x-podman:
10-
uidmaps:
11-
- "0:1:1"
12-
- "999:0:1"
13-
gidmaps:
14-
- "0:1:1"
15-
- "999:0:1"
9+
x-podman.uidmaps:
10+
- "0:1:1"
11+
- "999:0:1"
12+
x-podman.gidmaps:
13+
- "0:1:1"
14+
- "999:0:1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
import json
4+
import os
5+
import unittest
6+
7+
from tests.integration.test_utils import RunSubprocessMixin
8+
from tests.integration.test_utils import podman_compose_path
9+
from tests.integration.test_utils import test_path
10+
11+
12+
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
13+
def test_uidmaps(self):
14+
compose_path = os.path.join(test_path(), "uidmaps", "docker-compose.yml")
15+
try:
16+
self.run_subprocess_assert_returncode([
17+
podman_compose_path(),
18+
"-f",
19+
compose_path,
20+
"up",
21+
"-d",
22+
])
23+
24+
out, _ = self.run_subprocess_assert_returncode([
25+
"podman",
26+
"inspect",
27+
"uidmaps_touch_1",
28+
])
29+
30+
inspect_out = json.loads(out)
31+
host_config_map = inspect_out[0].get("HostConfig", {}).get("IDMappings", {})
32+
self.assertEqual(['0:1:1', '999:0:1'], host_config_map['UidMap'])
33+
self.assertEqual(['0:1:1', '999:0:1'], host_config_map['GidMap'])
34+
finally:
35+
out, _ = self.run_subprocess_assert_returncode([
36+
podman_compose_path(),
37+
"-f",
38+
compose_path,
39+
"down",
40+
])

0 commit comments

Comments
 (0)