xref: /unit/test/test_ruby_isolation.py (revision 2073:bc6ad31ce286)
1import pytest
2from unit.applications.lang.ruby import TestApplicationRuby
3from unit.option import option
4
5
6class TestRubyIsolation(TestApplicationRuby):
7    prerequisites = {'modules': {'ruby': 'any'}, 'features': ['isolation']}
8
9    def test_ruby_isolation_rootfs(self, is_su):
10        isolation_features = option.available['features']['isolation'].keys()
11
12        if not is_su:
13            if not 'unprivileged_userns_clone' in isolation_features:
14                pytest.skip('requires unprivileged userns or root')
15
16            if 'user' not in isolation_features:
17                pytest.skip('user namespace is not supported')
18
19            if 'mnt' not in isolation_features:
20                pytest.skip('mnt namespace is not supported')
21
22            if 'pid' not in isolation_features:
23                pytest.skip('pid namespace is not supported')
24
25        isolation = {'rootfs': option.temp_dir}
26
27        if not is_su:
28            isolation['namespaces'] = {
29                'mount': True,
30                'credential': True,
31                'pid': True,
32            }
33
34        self.load('status_int', isolation=isolation)
35
36        assert 'success' in self.conf(
37            '"/ruby/status_int/config.ru"',
38            'applications/status_int/script',
39        )
40
41        assert 'success' in self.conf(
42            '"/ruby/status_int"',
43            'applications/status_int/working_directory',
44        )
45
46        assert self.get()['status'] == 200, 'status int'
47