summaryrefslogtreecommitdiffhomepage
path: root/test/test_python_isolation_chroot.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_python_isolation_chroot.py')
-rw-r--r--test/test_python_isolation_chroot.py47
1 files changed, 19 insertions, 28 deletions
diff --git a/test/test_python_isolation_chroot.py b/test/test_python_isolation_chroot.py
index 349ec869..60fac5ef 100644
--- a/test/test_python_isolation_chroot.py
+++ b/test/test_python_isolation_chroot.py
@@ -1,38 +1,29 @@
-import pytest
-from unit.applications.lang.python import TestApplicationPython
+from unit.applications.lang.python import ApplicationPython
+prerequisites = {'modules': {'python': 'any'}, 'privileged_user': True}
-class TestPythonIsolation(TestApplicationPython):
- prerequisites = {'modules': {'python': 'any'}}
+client = ApplicationPython()
- def test_python_isolation_chroot(self, is_su, temp_dir):
- if not is_su:
- pytest.skip('requires root')
- isolation = {
- 'rootfs': temp_dir,
- }
+def test_python_isolation_chroot(temp_dir):
+ client.load('ns_inspect', isolation={'rootfs': temp_dir})
- self.load('ns_inspect', isolation=isolation)
+ assert not (
+ client.getjson(url=f'/?path={temp_dir}')['body']['FileExists']
+ ), 'temp_dir does not exists in rootfs'
- assert (
- self.getjson(url=f'/?path={temp_dir}')['body']['FileExists']
- == False
- ), 'temp_dir does not exists in rootfs'
+ assert client.getjson(url='/?path=/proc/self')['body'][
+ 'FileExists'
+ ], 'no /proc/self'
- assert (
- self.getjson(url='/?path=/proc/self')['body']['FileExists'] == True
- ), 'no /proc/self'
+ assert not (
+ client.getjson(url='/?path=/dev/pts')['body']['FileExists']
+ ), 'no /dev/pts'
- assert (
- self.getjson(url='/?path=/dev/pts')['body']['FileExists'] == False
- ), 'no /dev/pts'
+ assert not (
+ client.getjson(url='/?path=/sys/kernel')['body']['FileExists']
+ ), 'no /sys/kernel'
- assert (
- self.getjson(url='/?path=/sys/kernel')['body']['FileExists']
- == False
- ), 'no /sys/kernel'
+ ret = client.getjson(url='/?path=/app/python/ns_inspect')
- ret = self.getjson(url='/?path=/app/python/ns_inspect')
-
- assert ret['body']['FileExists'] == True, 'application exists in rootfs'
+ assert ret['body']['FileExists'], 'application exists in rootfs'