mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
3401445e8b
* Expose what's happening in `integration.states.user.UserTest.test_user_if_present_with_gid()`. * Update code that was using the old `SaltReturnAssertsMixIn`.
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
:copyright: © 2012 UfSoft.org - :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
:license: Apache 2.0, see LICENSE for more details
|
|
"""
|
|
|
|
# Import python libs
|
|
import os
|
|
import shutil
|
|
|
|
# Import salt libs
|
|
import integration
|
|
from saltunittest import skipIf, destructiveTest
|
|
|
|
|
|
class VirtualenvTest(integration.ModuleCase,
|
|
integration.SaltReturnAssertsMixIn):
|
|
|
|
@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]):
|
|
# Left behind on a canceled test run?
|
|
self.run_function('user.delete', [user, True, True])
|
|
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 = os.path.join(
|
|
integration.SYS_TMP_DIR, 'issue-1959-virtualenv-runas'
|
|
)
|
|
try:
|
|
ret = self.run_function(
|
|
'state.sls', mods='issue-1959-virtualenv-runas'
|
|
)
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
# 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])
|