xref: /unit/test/test_go_isolation_rootfs.py (revision 1848:4bd548074e2c)
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'
30