Merge pull request #9090 from terminalmage/issue9085

Fix user.present states with non-string fullname
This commit is contained in:
Colton Myers 2013-12-06 15:10:39 -08:00
commit 1be4c32c77
2 changed files with 20 additions and 0 deletions

View File

@ -227,6 +227,7 @@ def present(name,
homephone
The user's home phone number (not supported in MacOS)
'''
fullname = str(fullname) if fullname is not None else fullname
roomnumber = str(roomnumber) if roomnumber is not None else roomnumber
workphone = str(workphone) if workphone is not None else workphone
homephone = str(homephone) if homephone is not None else homephone

View File

@ -127,6 +127,25 @@ class UserTest(integration.ModuleCase,
ret = self.run_state('group.absent', name='salt_test')
self.assertSaltTrueReturn(ret)
@destructiveTest
@skipIf(os.geteuid() != 0, 'you must be root to run this test')
def test_user_present_gecos(self):
'''
This is a DESTRUCTIVE TEST it creates a new user on the on the minion.
It ensures that numeric GECOS data will be properly coerced to strings,
otherwise the state will fail because the GECOS fields are written as
strings (and show up in the user.info output as such). Thus the
comparison will fail, since '12345' != 12345.
'''
ret = self.run_state(
'user.present', name='salt_test', fullname=12345, roomnumber=123,
workphone=1234567890, homephone=1234567890
)
self.assertSaltTrueReturn(ret)
ret = self.run_state('user.absent', name='salt_test')
self.assertSaltTrueReturn(ret)
if __name__ == '__main__':
from integration import run_tests