xref: /unit/test/test_go_isolation_rootfs.py (revision 1999:00d43b03d82f)
1import os
2
3import pytest
4from unit.applications.lang.go import TestApplicationGo
5
6
7class TestGoIsolationRootfs(TestApplicationGo):
8    prerequisites = {'modules': {'go': 'all'}}
9
10    @pytest.fixture(autouse=True)
11    def setup_method_fixture(self, request, skip_alert):
12        skip_alert(r'\[unit\] close\(\d+\) failed: Bad file descriptor')
13
14    def test_go_isolation_rootfs_chroot(self, is_su, temp_dir):
15        if not is_su:
16            pytest.skip('requires root')
17
18        if os.uname().sysname == 'Darwin':
19            pytest.skip('chroot tests not supported on OSX')
20
21        isolation = {
22            'rootfs': temp_dir,
23        }
24
25        self.load('ns_inspect', isolation=isolation)
26
27        obj = self.getjson(url='/?file=/go/app')['body']
28
29        assert obj['FileExists'] == True, 'app relative to rootfs'
30
31        obj = self.getjson(url='/?file=/bin/sh')['body']
32        assert obj['FileExists'] == False, 'file should not exists'
33