コード例 #1
0
ファイル: test.py プロジェクト: prymitive/pumpkin
 def test_get_parent_new(self):
     """Test get_parent() method on new object
     """
     pg = PosixGroup(LDAP_CONN)
     pg.name = u'test_get_parent'
     pg.gid = 4
     self.assertEqual(pg.get_parent(), pg.directory.get_basedn())
コード例 #2
0
ファイル: test.py プロジェクト: prymitive/pumpkin
    def test_rename(self):
        """Test saving renamed object
        """
        pg = PosixGroup(LDAP_CONN)
        pg.name = u'test_rename_before'
        pg.gid = 54345
        pg.save()

        pg2 = PosixGroup(LDAP_CONN, pg.dn)
        pg2.name = u'test_rename_after'
        pg2.update()
        self.assertEqual(pg2.name, u'test_rename_before')
        pg2.name = u'test_rename_after'
        pg2.save()
        self.assertEqual(pg2.dn, 'cn=test_rename_after,dc=company,dc=com')
        pg2.delete()
コード例 #3
0
ファイル: test.py プロジェクト: prymitive/pumpkin
 def test_delete(self):
     """Test object deletion
     """
     pg = PosixGroup(LDAP_CONN)
     pg.name = u'TestDelete'
     pg.gid = 9351
     pg.members = [23, 32]
     pg.set_parent('ou=groups,dc=company,dc=com')
     pg.save()
     pg.delete()
     self.assertEqual(pg.isnew(), True)
     self.assertEqual(
         pg.dn, u'cn=TestDelete,ou=groups,dc=company,dc=com')
     pg.set_parent(u'dc=company,dc=com')
     pg.name = u'TestDelete2'
     pg.save()
     self.assertEqual(pg.dn, u'cn=TestDelete2,dc=company,dc=com')
     pg.delete()
コード例 #4
0
ファイル: test.py プロジェクト: prymitive/pumpkin
    def test_create_object(self):
        """Test creating new object, removing single attribute, deleting object
        """
        pg = PosixGroup(LDAP_CONN)
        pg.name = u'Test group'
        pg.gid = 1234
        pg.members = [1, 2, 3, 4, 5]
        pg.remove_member(3)
        pg.set_parent('ou=groups,dc=company,dc=com')
        pg.save()

        self.assertEqual(pg.dn, 'cn=Test group,ou=groups,dc=company,dc=com')

        del pg.members
        pg.save()

        pgtest = PosixGroup(LDAP_CONN, pg.dn)
        self.assertEqual(pgtest.object_class, [u'posixGroup'])
        self.assertEqual(pgtest.name, u'Test group')
        self.assertEqual(pgtest.gid, 1234)
        self.assertEqual(pgtest.members, [])

        pg.delete()
コード例 #5
0
ファイル: test.py プロジェクト: prymitive/pumpkin
    def test_posixgroup(self):
        """Test PosixGroup methods
        """
        ou = Unit(LDAP_CONN)
        ou.name = u"posix_group"
        ou.save()

        pu = PosixUser(LDAP_CONN)
        pu.set_parent(ou.dn)
        pu.uid = 8361
        pu.gid = 8245
        pu.login = u"login"
        pu.surname = u"Surname"
        pu.fullname = u"Fullname"
        pu.home = u"/home"
        pu.save()

        pg = PosixGroup(LDAP_CONN)
        pg.set_parent(ou.dn)
        pg.name = u"group"
        pg.gid = 45921
        pg.save()
        self.assertFalse(pg.ismember(pu.uid))

        pg.add_member(pu.uid)
        pg.save()
        pg.update()
        pu.update()
        self.assertEqual(pu.gid, pg.gid)
        self.assertRaises(ValueError, pg.remove_member, 1)

        pg.remove_member(pu.uid)
        pg.save()
        pg.update()
        self.assertFalse(pg.ismember(pu.uid))

        ou.delete(recursive=True)