Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test_runas integration test for macosx #48928

Merged
merged 4 commits into from Aug 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions tests/integration/modules/test_cmdmod.py
Expand Up @@ -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
Expand Down Expand Up @@ -266,12 +277,17 @@ def test_quotes_runas(self):

@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):
'''
Expand Down