mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add test case for #1959.
This commit is contained in:
parent
420bfe830b
commit
064b3a60c2
@ -109,8 +109,12 @@ def _run(cmd,
|
||||
if not runas:
|
||||
log.info('Executing command {0} in directory {1}'.format(cmd, cwd))
|
||||
else:
|
||||
log.info('Executing command {0} as user {1} in directory {2}'.format(
|
||||
orig_cmd, runas, cwd))
|
||||
log.info(
|
||||
'Executing command {0} as user {1} in directory {2}'.format(
|
||||
orig_cmd, runas, cwd
|
||||
)
|
||||
)
|
||||
log.debug('Actual command line to execute: {0!r}'.format(cmd))
|
||||
|
||||
run_env = os.environ
|
||||
run_env.update(env)
|
||||
|
@ -0,0 +1,4 @@
|
||||
/tmp/issue-1959-virtualenv-runas:
|
||||
virtualenv.manage:
|
||||
- requirements: salt://issue-1959-virtualenv-runas/requirements.txt
|
||||
- runas: issue-1959
|
@ -0,0 +1,2 @@
|
||||
meld3==0.6.9
|
||||
supervisor==3.0b1
|
46
tests/integration/states/virtualenv.py
Normal file
46
tests/integration/states/virtualenv.py
Normal file
@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: sw=4 ts=4 fenc=utf-8
|
||||
"""
|
||||
:copyright: © 2012 UfSoft.org - :email:`Pedro Algarvio (pedro@algarvio.me)`
|
||||
:license: BSD, see LICENSE for more details
|
||||
"""
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import shutil
|
||||
import integration
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import skipIf, destructiveTest
|
||||
|
||||
|
||||
class VirtualenvTest(integration.ModuleCase):
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(os.geteuid() is not 0, 'you must be this root to run this test')
|
||||
def test_issue_1959_virtualenv_runas(self):
|
||||
user = 'issue-1959'
|
||||
if not self.run_function('user.add', [user]):
|
||||
self.skipTest('Failed to create the \'{0}\' user'.format(user))
|
||||
|
||||
uinfo = self.run_function('user.info', [user])
|
||||
|
||||
venv_dir = '/tmp/issue-1959-virtualenv-runas'
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.sls', mods='issue-1959-virtualenv-runas'
|
||||
)
|
||||
self.assertTrue(isinstance(ret, dict))
|
||||
self.assertNotEqual(ret, {})
|
||||
for part in ret.itervalues():
|
||||
self.assertTrue(part['result'])
|
||||
|
||||
# Lets check proper ownership
|
||||
statinfo = self.run_function('file.stats', [venv_dir])
|
||||
self.assertEqual(statinfo['user'], uinfo['name'])
|
||||
self.assertEqual(statinfo['uid'], uinfo['uid'])
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
|
||||
self.run_function('user.delete', [user, True, True])
|
Loading…
Reference in New Issue
Block a user