Skip to content

Commit

Permalink
Convert ugm samba users doctests to unittests done
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed Apr 14, 2019
1 parent f8995b4 commit f8482d1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/node/ext/ldap/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_suite():
from node.ext.ldap.tests import test_ugm_group_of_names
from node.ext.ldap.tests import test_ugm_posix_groups
from node.ext.ldap.tests import test_ugm_principals
from node.ext.ldap.tests import test_ugm_samba_users

suite = unittest.TestSuite()

Expand All @@ -30,6 +31,7 @@ def test_suite():
suite.addTest(unittest.findTestCases(test_ugm_group_of_names))
suite.addTest(unittest.findTestCases(test_ugm_posix_groups))
suite.addTest(unittest.findTestCases(test_ugm_principals))
suite.addTest(unittest.findTestCases(test_ugm_samba_users))

return suite

Expand Down
41 changes: 41 additions & 0 deletions src/node/ext/ldap/tests/test_ugm_samba_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from node.tests import NodeTestCase
from node.ext.ldap import testing
from node.ext.ldap.ugm import Ugm


class TestUGMSambaUsers(NodeTestCase):
layer = testing.LDIF_sambaUsers

def test_samba_users(self):
ucfg = self.layer['ucfg']
gcfg = self.layer['gcfg']
props = self.layer['props']

ugm = Ugm(props=props, ucfg=ucfg, gcfg=gcfg)
self.assertEqual(
ugm.users.search(),
[u'uid0', u'uid1', u'uid2']
)
self.assertEqual(
ugm.users['uid0'].context.attrs['userPassword'],
u'secret0'
)
self.assertEqual(
ugm.users['uid0'].context.attrs['sambaLMPassword'],
u'FF3750BCC2B22412AAD3B435B51404EE'
)
self.assertEqual(
ugm.users['uid0'].context.attrs['sambaNTPassword'],
u'62CF067F093CD75BBAA5D49E04689ED7'
)
ugm.users['uid0'].passwd('secret0', 'newsecret')
password = ugm.users['uid0'].context.attrs['userPassword']
self.assertTrue(password.startswith('{SSHA}'))
self.assertEqual(
ugm.users['uid0'].context.attrs['sambaLMPassword'],
u'DB6574A2642D294B9A0F5D12D8F612D0'
)
self.assertEqual(
ugm.users['uid0'].context.attrs['sambaNTPassword'],
u'58D9F1588236EE9D4ED739E89FFCA25B'
)

0 comments on commit f8482d1

Please sign in to comment.