test_php_isolation.py (1490:cecf6b11a1e3) test_php_isolation.py (1584:639ad4601177)
1import unittest
2
3from unit.applications.lang.php import TestApplicationPHP
4from unit.feature.isolation import TestFeatureIsolation
5
6
7class TestPHPIsolation(TestApplicationPHP):
8 prerequisites = {'modules': {'php': 'any'}, 'features': ['isolation']}

--- 38 unchanged lines hidden (view full) ---

47 'success',
48 self.conf(
49 '"/php/phpinfo"', 'applications/phpinfo/working_directory'
50 ),
51 )
52
53 self.assertEqual(self.get()['status'], 200, 'empty rootfs')
54
1import unittest
2
3from unit.applications.lang.php import TestApplicationPHP
4from unit.feature.isolation import TestFeatureIsolation
5
6
7class TestPHPIsolation(TestApplicationPHP):
8 prerequisites = {'modules': {'php': 'any'}, 'features': ['isolation']}

--- 38 unchanged lines hidden (view full) ---

47 'success',
48 self.conf(
49 '"/php/phpinfo"', 'applications/phpinfo/working_directory'
50 ),
51 )
52
53 self.assertEqual(self.get()['status'], 200, 'empty rootfs')
54
55 def test_php_isolation_rootfs_extensions(self):
56 isolation_features = self.available['features']['isolation'].keys()
55
57
58 if not self.is_su:
59 if 'user' not in isolation_features:
60 print('requires unprivileged userns or root')
61 raise unittest.SkipTest()
62
63 if not 'unprivileged_userns_clone' in isolation_features:
64 print('requires unprivileged userns or root')
65 raise unittest.SkipTest()
66
67 if 'mnt' not in isolation_features:
68 print('requires mnt ns')
69 raise unittest.SkipTest()
70
71 isolation = {
72 'rootfs': self.current_dir,
73 'namespaces': {
74 'credential': not self.is_su,
75 'mount': not self.is_su,
76 },
77 }
78
79 self.load('list-extensions', isolation=isolation)
80
81 self.assertIn(
82 'success',
83 self.conf(
84 '"/php/list-extensions"', 'applications/list-extensions/root'
85 ),
86 )
87
88 self.assertIn(
89 'success',
90 self.conf(
91 {'file': '/php/list-extensions/php.ini'},
92 'applications/list-extensions/options',
93 ),
94 )
95
96 self.assertIn(
97 'success',
98 self.conf(
99 '"/php/list-extensions"',
100 'applications/list-extensions/working_directory',
101 ),
102 )
103
104 extensions = self.getjson()['body']
105
106 self.assertIn('json', extensions, 'json in extensions list')
107 self.assertIn('unit', extensions, 'unit in extensions list')
108
109
56if __name__ == '__main__':
57 TestPHPIsolation.main()
110if __name__ == '__main__':
111 TestPHPIsolation.main()