From 788abf771ee7c58bab2d88330a8dbc8712cf2c0f Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Thu, 24 May 2018 11:46:02 -0400 Subject: [PATCH] Add user state integration tests to windows --- tests/integration/states/test_user.py | 26 +++++++++++++++++++++----- tests/whitelist.txt | 1 + 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/integration/states/test_user.py b/tests/integration/states/test_user.py index be46cbf7be..1f8596c415 100644 --- a/tests/integration/states/test_user.py +++ b/tests/integration/states/test_user.py @@ -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. diff --git a/tests/whitelist.txt b/tests/whitelist.txt index b7cb036881..dcea166039 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -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