예제 #1
0
파일: testmail.py 프로젝트: AnatomicJC/mmc
class TestMailControlVDomain(unittest.TestCase):

    def setUp(self):
        cleanLdap()
        self.m = MailControl(conffile = "tests-mds/vdomaintest.ini", conffilebase = "tests-mds/basetest.ini")

    def test_MailControl(self):
        self.m.addUser("usertest", "userpass", "test", "test", "/home/mail/usertest", False)
        self.m.addMailObjectClass("usertest", "usertestmail")
        d = self.m.getDetailedUser("usertest")
        self.assertEqual(d["mailbox"][0], "/home/mail/usertest/Maildir")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), True)
        self.m.removeUserObjectClass("usertest", "mailAccount")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), False)

    def test_VDomains(self):
        self.assertEqual(len(self.m.getVDomains("")), 0)
        self.m.addVDomain("mandriva.com")
        self.assertEqual(len(self.m.getVDomains("")), 1)
        self.assertEqual(len(self.m.getVDomain("mandriva.com")), 1)
        self.assertEqual(self.m.getVDomain("mandriva.com")[0][1]["virtualdomain"], ["mandriva.com"])
        self.m.setVDomainDescription("mandriva.com", "test")
        self.assertEqual(self.m.getVDomain("mandriva.com")[0][1]["virtualdomaindescription"], ["test"])
        self.assertEqual(self.m.getVDomainUsersCount("mandriva.com"), 0)

        self.m.addUser("usertest", "userpass", "test", "test")
        self.m.addMailObjectClass("usertest", "usertestmail")
        self.assertEqual(self.m.getVDomainUsersCount("mandriva.com"), 1)
        self.assertEqual(self.m.getVDomainUsers("mandriva.com", ""), [('uid=usertest,ou=Users,dc=mandriva,dc=com', {'mail': ['*****@*****.**'], 'givenName': ['test'], 'uid': ['usertest'], 'sn': ['test']})])

        self.m.delVDomain("mandriva.com")
        self.assertEqual(len(self.m.getVDomains("")), 0)
예제 #2
0
파일: testmail.py 프로젝트: AnatomicJC/mmc
class TestMailControl(unittest.TestCase):

    def setUp(self):
        cleanLdap()
        self.m = MailControl(conffile = "tests-mds/vdomaintest.ini", conffilebase = "tests-mds/basetest.ini")

    def test_MailControl(self):
        self.m.addUser("usertest", "userpass", "test", "test")
        self.m.addMailObjectClass("usertest", "usertestmail")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), True)
        self.m.removeUserObjectClass("usertest", "mailAccount")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), False)
예제 #3
0
class TestMailControl(unittest.TestCase):
    def setUp(self):
        cleanLdap()
        self.m = MailControl(conffile="tests-mds/vdomaintest.ini",
                             conffilebase="tests-mds/basetest.ini")

    def test_MailControl(self):
        self.m.addUser("usertest", "userpass", "test", "test")
        self.m.addMailObjectClass("usertest", "usertestmail")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), True)
        self.m.removeUserObjectClass("usertest", "mailAccount")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), False)
예제 #4
0
class TestMailControlVDomain(unittest.TestCase):
    def setUp(self):
        cleanLdap()
        self.m = MailControl(conffile="tests-mds/vdomaintest.ini",
                             conffilebase="tests-mds/basetest.ini")

    def test_MailControl(self):
        self.m.addUser("usertest", "userpass", "test", "test",
                       "/home/mail/usertest", False)
        self.m.addMailObjectClass("usertest", "usertestmail")
        d = self.m.getDetailedUser("usertest")
        self.assertEqual(d["mailbox"][0], "/home/mail/usertest/Maildir")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), True)
        self.m.removeUserObjectClass("usertest", "mailAccount")
        self.assertEqual(self.m.hasMailObjectClass("usertest"), False)

    def test_VDomains(self):
        self.assertEqual(len(self.m.getVDomains("")), 0)
        self.m.addVDomain("mandriva.com")
        self.assertEqual(len(self.m.getVDomains("")), 1)
        self.assertEqual(len(self.m.getVDomain("mandriva.com")), 1)
        self.assertEqual(
            self.m.getVDomain("mandriva.com")[0][1]["virtualdomain"],
            ["mandriva.com"])
        self.m.setVDomainDescription("mandriva.com", "test")
        self.assertEqual(
            self.m.getVDomain("mandriva.com")[0][1]
            ["virtualdomaindescription"], ["test"])
        self.assertEqual(self.m.getVDomainUsersCount("mandriva.com"), 0)

        self.m.addUser("usertest", "userpass", "test", "test")
        self.m.addMailObjectClass("usertest", "usertestmail")
        self.assertEqual(self.m.getVDomainUsersCount("mandriva.com"), 1)
        self.assertEqual(self.m.getVDomainUsers("mandriva.com", ""),
                         [('uid=usertest,ou=Users,dc=mandriva,dc=com', {
                             'mail': ['*****@*****.**'],
                             'givenName': ['test'],
                             'uid': ['usertest'],
                             'sn': ['test']
                         })])

        self.m.delVDomain("mandriva.com")
        self.assertEqual(len(self.m.getVDomains("")), 0)