mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #48928 from Ch3LL/mac_runas
fix test_runas integration test for macosx
This commit is contained in:
commit
abd7f1312d
1 changed files with 18 additions and 2 deletions
|
@ -38,6 +38,17 @@ class CMDModuleTest(ModuleCase):
|
|||
'''
|
||||
Validate the cmd module
|
||||
'''
|
||||
def setUp(self):
|
||||
self.runas_usr = 'nobody'
|
||||
if salt.utils.platform.is_darwin():
|
||||
self.runas_usr = 'macsalttest'
|
||||
|
||||
def tearDown(self):
|
||||
if self._testMethodName == 'test_runas':
|
||||
if salt.utils.platform.is_darwin():
|
||||
if self.runas_usr in self.run_function('user.info', [self.runas_usr]).values():
|
||||
self.run_function('user.delete', [self.runas_usr], remove=True)
|
||||
|
||||
def test_run(self):
|
||||
'''
|
||||
cmd.run
|
||||
|
@ -266,12 +277,17 @@ class CMDModuleTest(ModuleCase):
|
|||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'minion is windows')
|
||||
@skip_if_not_root
|
||||
@destructiveTest
|
||||
def test_runas(self):
|
||||
'''
|
||||
Ensure that the env is the runas user's
|
||||
'''
|
||||
out = self.run_function('cmd.run', ['env'], runas='nobody').splitlines()
|
||||
self.assertIn('USER=nobody', out)
|
||||
if salt.utils.platform.is_darwin():
|
||||
if self.runas_usr not in self.run_function('user.info', [self.runas_usr]).values():
|
||||
self.run_function('user.add', [self.runas_usr])
|
||||
|
||||
out = self.run_function('cmd.run', ['env'], runas=self.runas_usr).splitlines()
|
||||
self.assertIn('USER={0}'.format(self.runas_usr), out)
|
||||
|
||||
def test_timeout(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue