Add user state integration tests to windows

This commit is contained in:
Ch3LL 2018-05-24 11:46:02 -04:00
parent c9cccf53b9
commit 788abf771e
No known key found for this signature in database
GPG Key ID: 132B55A7C13EFA73
2 changed files with 22 additions and 5 deletions

View File

@ -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)
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():
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.

View File

@ -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