1import os 2 3import pytest 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' 29