Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Porting #52786 to master #54588

Merged
merged 3 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'])