From ad4819ff66ce34bdf1b0ac33d6f2de108e363a45 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 19 Mar 2009 15:44:34 -0400 Subject: Add tests for posix groups --- tests/test_xmlrpc/test_group_plugin.py | 66 +++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py index 23c9b050..c40f4c9d 100644 --- a/tests/test_xmlrpc/test_group_plugin.py +++ b/tests/test_xmlrpc/test_group_plugin.py @@ -33,12 +33,13 @@ class test_Group(XMLRPC_test): """ cn = u'testgroup' cn2 = u'testgroup2' + cnposix = u'posixgroup' description = u'This is a test' kw={'description':description,'cn':cn} def test_add(self): """ - Test the `xmlrpc.group_add` method. + Test the `xmlrpc.group_add` method: testgroup. """ res = api.Command['group_add'](**self.kw) assert res @@ -56,7 +57,7 @@ class test_Group(XMLRPC_test): def test_add3(self): """ - Test the `xmlrpc.group_add` method. + Test the `xmlrpc.group_add` method: testgroup2. """ self.kw['cn'] = self.cn2 res = api.Command['group_add'](**self.kw) @@ -64,6 +65,19 @@ class test_Group(XMLRPC_test): assert res.get('description','') == self.description assert res.get('cn','') == self.cn2 + def test_addposix(self): + """ + Test the `xmlrpc.group_add` method: posixgroup + """ + posixkw = {} + posixkw['cn'] = self.cnposix + posixkw['description'] = self.description + posixkw['posix'] = True + res = api.Command['group_add'](**posixkw) + assert res + assert res.get('description','') == self.description + assert res.get('cn','') == self.cnposix + def test_add_member(self): """ Test the `xmlrpc.group_add_member` method. @@ -93,6 +107,16 @@ class test_Group(XMLRPC_test): assert res.get('cn','') == self.cn assert res.get('member','').startswith('cn=%s' % self.cn2) + def test_doshowposix(self): + """ + Test the `xmlrpc.group_show` method for a posix group. + """ + res = api.Command['group_show'](self.cnposix) + assert res + assert res.get('description','') == self.description + assert res.get('cn','') == self.cnposix + assert res.get('gidnumber',None) + def test_find(self): """ Test the `xmlrpc.group_find` method. @@ -120,6 +144,25 @@ class test_Group(XMLRPC_test): assert res.get('description','') == 'New description' assert res.get('cn','') == self.cn + def test_mod2(self): + """ + Test the `xmlrpc.group_mod` method, promote a posix group + """ + modkw = self.kw + modkw['cn'] = self.cn + modkw['posix'] = True + res = api.Command['group_mod'](**modkw) + assert res + assert res.get('description','') == 'New description' + assert res.get('gidnumber','') + + # Ok, double-check that it was changed + res = api.Command['group_show'](self.cn) + assert res + assert res.get('description','') == 'New description' + assert res.get('cn','') == self.cn + assert res.get('gidnumber','') + def test_remove_member(self): """ Test the `xmlrpc.group_remove_member` method. @@ -144,7 +187,7 @@ class test_Group(XMLRPC_test): def test_remove_x(self): """ - Test the `xmlrpc.group_del` method. + Test the `xmlrpc.group_del` method: testgroup. """ res = api.Command['group_del'](self.cn) assert res == True @@ -159,7 +202,7 @@ class test_Group(XMLRPC_test): def test_remove_x2(self): """ - Test the `xmlrpc.group_del` method. + Test the `xmlrpc.group_del` method: testgroup2. """ res = api.Command['group_del'](self.cn2) assert res == True @@ -171,3 +214,18 @@ class test_Group(XMLRPC_test): pass else: assert False + + def test_remove_x3(self): + """ + Test the `xmlrpc.group_del` method: posixgroup. + """ + res = api.Command['group_del'](self.cnposix) + assert res == True + + # Verify that it is gone + try: + res = api.Command['group_show'](self.cnposix) + except errors2.NotFound: + pass + else: + assert False -- cgit