Deleted
Added
test_go_isolation.py (1730:44912af5b3e6) | test_go_isolation.py (1740:53149d20bb97) |
---|---|
1import grp 2import os 3import pwd 4import shutil 5 6import pytest 7 | 1import grp 2import os 3import pwd 4import shutil 5 6import pytest 7 |
8from conftest import unit_run 9from conftest import unit_stop | |
10from unit.applications.lang.go import TestApplicationGo | 8from unit.applications.lang.go import TestApplicationGo |
11from unit.feature.isolation import TestFeatureIsolation | |
12from unit.option import option | 9from unit.option import option |
10from unit.utils import getns |
|
13 14class TestGoIsolation(TestApplicationGo): 15 prerequisites = {'modules': {'go': 'any'}, 'features': ['isolation']} 16 | 11 12class TestGoIsolation(TestApplicationGo): 13 prerequisites = {'modules': {'go': 'any'}, 'features': ['isolation']} 14 |
17 isolation = TestFeatureIsolation() 18 19 @classmethod 20 def setup_class(cls, complete_check=True): 21 check = super().setup_class(complete_check=False) 22 23 unit = unit_run() 24 option.temp_dir = unit['temp_dir'] 25 26 TestFeatureIsolation().check(option.available, unit['temp_dir']) 27 28 assert unit_stop() is None 29 shutil.rmtree(unit['temp_dir']) 30 31 return check if not complete_check else check() 32 | |
33 def unpriv_creds(self): 34 nobody_uid = pwd.getpwnam('nobody').pw_uid 35 36 try: 37 nogroup_gid = grp.getgrnam('nogroup').gr_gid 38 nogroup = 'nogroup' 39 except KeyError: 40 nogroup_gid = grp.getgrnam('nobody').gr_gid --- 173 unchanged lines hidden (view full) --- 214 215 for ns in allns: 216 if ns.upper() in obj['NS']: 217 assert ( 218 obj['NS'][ns.upper()] 219 == option.available['features']['isolation'][ns] 220 ), ('%s match' % ns) 221 | 15 def unpriv_creds(self): 16 nobody_uid = pwd.getpwnam('nobody').pw_uid 17 18 try: 19 nogroup_gid = grp.getgrnam('nogroup').gr_gid 20 nogroup = 'nogroup' 21 except KeyError: 22 nogroup_gid = grp.getgrnam('nobody').gr_gid --- 173 unchanged lines hidden (view full) --- 196 197 for ns in allns: 198 if ns.upper() in obj['NS']: 199 assert ( 200 obj['NS'][ns.upper()] 201 == option.available['features']['isolation'][ns] 202 ), ('%s match' % ns) 203 |
222 assert obj['NS']['MNT'] != self.isolation.getns('mnt'), 'mnt set' 223 assert obj['NS']['USER'] != self.isolation.getns('user'), 'user set' | 204 assert obj['NS']['MNT'] != getns('mnt'), 'mnt set' 205 assert obj['NS']['USER'] != getns('user'), 'user set' |
224 225 def test_isolation_pid(self, is_su): 226 if not self.isolation_key('pid'): 227 pytest.skip('pid namespace is not supported') 228 229 if not is_su: 230 if not self.isolation_key('unprivileged_userns_clone'): 231 pytest.skip('unprivileged clone is not available') --- 150 unchanged lines hidden --- | 206 207 def test_isolation_pid(self, is_su): 208 if not self.isolation_key('pid'): 209 pytest.skip('pid namespace is not supported') 210 211 if not is_su: 212 if not self.isolation_key('unprivileged_userns_clone'): 213 pytest.skip('unprivileged clone is not available') --- 150 unchanged lines hidden --- |