fix test_runas integration test for macosx

This commit is contained in:
Ch3LL 2018-08-03 14:57:15 -04:00
parent d23471262d
commit c0730ff968
No known key found for this signature in database
GPG Key ID: 132B55A7C13EFA73

View File

@ -38,6 +38,21 @@ class CMDModuleTest(ModuleCase):
'''
Validate the cmd module
'''
def setUp(self):
if self._testMethodName == 'test_runas':
# only need to manage this user for the test_runas test
self.runas_usr = 'nobody'
if salt.utils.platform.is_darwin():
self.runas_usr = 'macsalttest'
if self.runas_usr not in self.run_function('user.info', [self.runas_usr]).values():
self.run_function('user.add', [self.runas_usr])
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 +281,13 @@ 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)
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):
'''