mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Add user state integration tests to windows
This commit is contained in:
parent
c9cccf53b9
commit
788abf771e
@ -12,7 +12,6 @@ from __future__ import absolute_import
|
||||
import os
|
||||
import sys
|
||||
from random import randint
|
||||
import grp
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
@ -28,11 +27,18 @@ if salt.utils.is_darwin():
|
||||
GROUP = 'macuser'
|
||||
GID = randint(400, 500)
|
||||
NOGROUPGID = randint(400, 500)
|
||||
elif salt.utils.is_windows():
|
||||
USER = 'winuser'
|
||||
GROUP = 'winuser'
|
||||
GID = randint(400, 500)
|
||||
NOGROUPGID = randint(400, 500)
|
||||
grp = None
|
||||
else:
|
||||
USER = 'nobody'
|
||||
GROUP = 'nobody'
|
||||
GID = 'nobody'
|
||||
NOGROUPGID = 'nogroup'
|
||||
import grp
|
||||
|
||||
|
||||
@destructiveTest
|
||||
@ -41,8 +47,8 @@ class UserTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
'''
|
||||
test for user absent
|
||||
'''
|
||||
user_name = 'salt_test'
|
||||
user_home = '/var/lib/salt_test'
|
||||
user_name = 'salt-test'
|
||||
user_home = os.path.join('tmp', user_name)
|
||||
|
||||
def test_user_absent(self):
|
||||
ret = self.run_state('user.absent', name='unpossible')
|
||||
@ -101,16 +107,23 @@ class UserTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_function('user.info', [self.user_name])
|
||||
self.assertReturnNonEmptySaltType(ret)
|
||||
group_name = grp.getgrgid(ret['gid']).gr_name
|
||||
if not salt.utils.is_darwin():
|
||||
if salt.utils.is_windows():
|
||||
group_name = self.run_function('user.list_groups', [self.user_name])
|
||||
else:
|
||||
group_name = grp.getgrgid(ret['gid']).gr_name
|
||||
|
||||
if not salt.utils.is_darwin() and not salt.utils.is_windows():
|
||||
self.assertTrue(os.path.isdir(self.user_home))
|
||||
if grains['os_family'] in ('Suse',):
|
||||
self.assertEqual(group_name, 'users')
|
||||
elif grains['os_family'] == 'MacOS':
|
||||
self.assertEqual(group_name, 'staff')
|
||||
elif salt.utils.is_windows():
|
||||
self.assertEqual([], group_name)
|
||||
else:
|
||||
self.assertEqual(group_name, self.user_name)
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'windows minion does not support gid_from_name')
|
||||
@requires_system_grains
|
||||
def test_user_present_gid_from_name_default(self, grains=None):
|
||||
'''
|
||||
@ -145,6 +158,7 @@ class UserTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
else:
|
||||
self.assertEqual(group_name, self.user_name)
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'windows minion does not support gid_from_name')
|
||||
def test_user_present_gid_from_name(self):
|
||||
'''
|
||||
This is a DESTRUCTIVE TEST it creates a new user on the on the minion.
|
||||
@ -197,6 +211,7 @@ class UserTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@skipIf('salt.utils.is_windows', 'windows minon does not support roomnumber or phone')
|
||||
def test_user_present_gecos(self):
|
||||
'''
|
||||
This is a DESTRUCTIVE TEST it creates a new user on the on the minion.
|
||||
@ -216,6 +231,7 @@ class UserTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@skipIf('salt.utils.is_windows', 'windows minon does not support roomnumber or phone')
|
||||
def test_user_present_gecos_none_fields(self):
|
||||
'''
|
||||
This is a DESTRUCTIVE TEST it creates a new user on the on the minion.
|
||||
|
@ -39,6 +39,7 @@ integration.sdb.test_env
|
||||
integration.states.test_host
|
||||
integration.states.test_pip_state
|
||||
integration.states.test_renderers
|
||||
integration.states.test_user
|
||||
integration.utils.testprogram
|
||||
integration.wheel.test_client
|
||||
integration.wheel.test_key
|
||||
|
Loading…
Reference in New Issue
Block a user