Skip to content

Commit

Permalink
Merge pull request #54588 from garethgreenaway/2019_2_1_port_52786
Browse files Browse the repository at this point in the history
[master] Porting #52786 to master
  • Loading branch information
dwoz authored Nov 14, 2019
2 parents f5b4b14 + 005513b commit 3c5a791
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
8 changes: 4 additions & 4 deletions salt/states/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ def _changes(name,
if fullname is not None and lusr['fullname'] != fullname:
change['fullname'] = fullname
if win_homedrive and lusr['homedrive'] != win_homedrive:
change['homedrive'] = win_homedrive
change['win_homedrive'] = win_homedrive
if win_profile and lusr['profile'] != win_profile:
change['profile'] = win_profile
change['win_profile'] = win_profile
if win_logonscript and lusr['logonscript'] != win_logonscript:
change['logonscript'] = win_logonscript
change['win_logonscript'] = win_logonscript
if win_description and lusr['description'] != win_description:
change['description'] = win_description
change['win_description'] = win_description

# MacOS doesn't have full GECOS support, so check for the "ch" functions
# and ignore these parameters if these functions do not exist.
Expand Down
36 changes: 36 additions & 0 deletions tests/integration/states/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,39 @@ def tearDown(self):
self.assertSaltTrueReturn(
self.run_state('user.absent', name=self.user_name)
)


@destructiveTest
@skip_if_not_root
@skipIf(not salt.utils.platform.is_windows(), 'Windows only tests')
class WinUserTest(ModuleCase, SaltReturnAssertsMixin):
'''
test for user absent
'''
def tearDown(self):
self.assertSaltTrueReturn(
self.run_state('user.absent', name=USER)
)

def test_user_present_existing(self):
ret = self.run_state('user.present',
name=USER,
win_homedrive='U:',
win_profile='C:\\User\\{0}'.format(USER),
win_logonscript='C:\\logon.vbs',
win_description='Test User Account')
self.assertSaltTrueReturn(ret)
ret = self.run_state('user.present',
name=USER,
win_homedrive='R:',
win_profile='C:\\Users\\{0}'.format(USER),
win_logonscript='C:\\Windows\\logon.vbs',
win_description='Temporary Account')
self.assertSaltTrueReturn(ret)
self.assertSaltStateChangesEqual(ret, 'R:', keys=['homedrive'])
self.assertSaltStateChangesEqual(
ret, 'C:\\Users\\{0}'.format(USER), keys=['profile'])
self.assertSaltStateChangesEqual(
ret, 'C:\\Windows\\logon.vbs', keys=['logonscript'])
self.assertSaltStateChangesEqual(
ret, 'Temporary Account', keys=['description'])

0 comments on commit 3c5a791

Please sign in to comment.