summaryrefslogtreecommitdiffhomepage
path: root/test/test_go_isolation.py
diff options
context:
space:
mode:
authorTiago Natel de Moura <t.nateldemoura@f5.com>2020-10-29 20:30:53 +0000
committerTiago Natel de Moura <t.nateldemoura@f5.com>2020-10-29 20:30:53 +0000
commit0390cb3a61051dd93e206d50591aff5759cf42fc (patch)
treed2105e88cbe4ef30a25243d7ccb07fae706c1003 /test/test_go_isolation.py
parent417f5d911ddb3a46b590d89e73313856a32ff435 (diff)
downloadunit-0390cb3a61051dd93e206d50591aff5759cf42fc.tar.gz
unit-0390cb3a61051dd93e206d50591aff5759cf42fc.tar.bz2
Isolation: mounting of procfs by default when using "rootfs".
Diffstat (limited to 'test/test_go_isolation.py')
-rw-r--r--test/test_go_isolation.py80
1 files changed, 56 insertions, 24 deletions
diff --git a/test/test_go_isolation.py b/test/test_go_isolation.py
index 9a84aa25..c68925b9 100644
--- a/test/test_go_isolation.py
+++ b/test/test_go_isolation.py
@@ -226,13 +226,23 @@ class TestGoIsolation(TestApplicationGo):
if not self.isolation_key('pid'):
pytest.skip('pid namespace is not supported')
- if not (is_su or self.isolation_key('unprivileged_userns_clone')):
- pytest.skip('requires root or unprivileged_userns_clone')
+ if not is_su:
+ if not self.isolation_key('unprivileged_userns_clone'):
+ pytest.skip('unprivileged clone is not available')
- self.load(
- 'ns_inspect',
- isolation={'namespaces': {'pid': True, 'credential': True}},
- )
+ if not self.isolation_key('user'):
+ pytest.skip('user namespace is not supported')
+
+ if not self.isolation_key('mnt'):
+ pytest.skip('mnt namespace is not supported')
+
+ isolation = {'namespaces': {'pid': True}}
+
+ if not is_su:
+ isolation['namespaces']['mount'] = True
+ isolation['namespaces']['credential'] = True
+
+ self.load('ns_inspect', isolation=isolation)
obj = self.getjson()['body']
@@ -269,17 +279,28 @@ class TestGoIsolation(TestApplicationGo):
== option.available['features']['isolation'][ns]
), ('%s match' % ns)
- def test_go_isolation_rootfs_container(self, temp_dir):
- if not self.isolation_key('unprivileged_userns_clone'):
- pytest.skip('unprivileged clone is not available')
+ def test_go_isolation_rootfs_container(self, is_su, temp_dir):
+ if not is_su:
+ if not self.isolation_key('unprivileged_userns_clone'):
+ pytest.skip('unprivileged clone is not available')
- if not self.isolation_key('mnt'):
- pytest.skip('mnt namespace is not supported')
+ if not self.isolation_key('user'):
+ pytest.skip('user namespace is not supported')
- isolation = {
- 'namespaces': {'mount': True, 'credential': True},
- 'rootfs': temp_dir,
- }
+ if not self.isolation_key('mnt'):
+ pytest.skip('mnt namespace is not supported')
+
+ if not self.isolation_key('pid'):
+ pytest.skip('pid namespace is not supported')
+
+ isolation = {'rootfs': temp_dir}
+
+ if not is_su:
+ isolation['namespaces'] = {
+ 'mount': True,
+ 'credential': True,
+ 'pid': True
+ }
self.load('ns_inspect', isolation=isolation)
@@ -311,17 +332,28 @@ class TestGoIsolation(TestApplicationGo):
obj = self.getjson(url='/?file=/bin/sh')['body']
assert obj['FileExists'] == False, 'file should not exists'
- def test_go_isolation_rootfs_default_tmpfs(self, temp_dir):
- if not self.isolation_key('unprivileged_userns_clone'):
- pytest.skip('unprivileged clone is not available')
+ def test_go_isolation_rootfs_default_tmpfs(self, is_su, temp_dir):
+ if not is_su:
+ if not self.isolation_key('unprivileged_userns_clone'):
+ pytest.skip('unprivileged clone is not available')
- if not self.isolation_key('mnt'):
- pytest.skip('mnt namespace is not supported')
+ if not self.isolation_key('user'):
+ pytest.skip('user namespace is not supported')
- isolation = {
- 'namespaces': {'mount': True, 'credential': True},
- 'rootfs': temp_dir,
- }
+ if not self.isolation_key('mnt'):
+ pytest.skip('mnt namespace is not supported')
+
+ if not self.isolation_key('pid'):
+ pytest.skip('pid namespace is not supported')
+
+ isolation = {'rootfs': temp_dir}
+
+ if not is_su:
+ isolation['namespaces'] = {
+ 'mount': True,
+ 'credential': True,
+ 'pid': True
+ }
self.load('ns_inspect', isolation=isolation)