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