test_go_isolation_rootfs.py (1635:97afbb6c5a15) test_go_isolation_rootfs.py (1654:fc7d0578e124)
1import os
2
3import pytest
4
5from unit.applications.lang.go import TestApplicationGo
6
7
8class TestGoIsolationRootfs(TestApplicationGo):
9 prerequisites = {'modules': {'go': 'all'}}
10
1import os
2
3import pytest
4
5from unit.applications.lang.go import TestApplicationGo
6
7
8class TestGoIsolationRootfs(TestApplicationGo):
9 prerequisites = {'modules': {'go': 'all'}}
10
11 def test_go_isolation_rootfs_chroot(self, is_su):
11 def test_go_isolation_rootfs_chroot(self, is_su, temp_dir):
12 if not is_su:
13 pytest.skip('requires root')
14
15 if os.uname().sysname == 'Darwin':
16 pytest.skip('chroot tests not supported on OSX')
17
18 isolation = {
12 if not is_su:
13 pytest.skip('requires root')
14
15 if os.uname().sysname == 'Darwin':
16 pytest.skip('chroot tests not supported on OSX')
17
18 isolation = {
19 'rootfs': self.temp_dir,
19 'rootfs': temp_dir,
20 }
21
22 self.load('ns_inspect', isolation=isolation)
23
24 obj = self.getjson(url='/?file=/go/app')['body']
25
26 assert obj['FileExists'] == True, 'app relative to rootfs'
27
28 obj = self.getjson(url='/?file=/bin/sh')['body']
29 assert obj['FileExists'] == False, 'file should not exists'
20 }
21
22 self.load('ns_inspect', isolation=isolation)
23
24 obj = self.getjson(url='/?file=/go/app')['body']
25
26 assert obj['FileExists'] == True, 'app relative to rootfs'
27
28 obj = self.getjson(url='/?file=/bin/sh')['body']
29 assert obj['FileExists'] == False, 'file should not exists'