Exemple #1
0
 def test_create_email_account(self):
     """Create email account; return email account object."""
     first = 'create_email'
     last = 'account_test'
     user_id = first + last
     email_addr = first + last + '@' + self.email_dom
     user = SpokeUser(self.org_name)
     user.create(email_addr, first, last)
     
     org = '%s=%s' % (self.org_attr, self.org_name)
     people = '%s=%s' % (self.container_attr, self.user_container)
     uid = '%s=%s' % (self.user_key, user_id)
     dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn)
     dn_info = {'objectClass': ['top', 'inetOrgPerson', self.user_class,
                                 self.imap_class, self.smtp_class],
                self.imap_enable: ['TRUE'],
                self.imap_mailbox: [user_id],
                self.imap_domain: [self.email_dom],
                self.imap_partition: [self.imap_partition_def],
                self.smtp_destination: [email_addr],
                self.smtp_enable: ['TRUE'],
                self.smtp_pri_address: [email_addr]
                }
     expected_result = [(dn, dn_info)]        
     acc = SpokeEmailAccount(self.org_name, user_id)
     result = acc.create(email_addr)['data']
     self.assertEqual(result, expected_result)
     user.delete(first, last)
Exemple #2
0
    def test_create_email_account(self):
        """Create email account; return email account object."""
        first = 'create_email'
        last = 'account_test'
        user_id = first + last
        email_addr = first + last + '@' + self.email_dom
        user = SpokeUser(self.org_name)
        user.create(email_addr, first, last)

        org = '%s=%s' % (self.org_attr, self.org_name)
        people = '%s=%s' % (self.container_attr, self.user_container)
        uid = '%s=%s' % (self.user_key, user_id)
        dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn)
        dn_info = {
            'objectClass': [
                'top', 'inetOrgPerson', self.user_class, self.imap_class,
                self.smtp_class
            ],
            self.imap_enable: ['TRUE'],
            self.imap_mailbox: [user_id],
            self.imap_domain: [self.email_dom],
            self.imap_partition: [self.imap_partition_def],
            self.smtp_destination: [email_addr],
            self.smtp_enable: ['TRUE'],
            self.smtp_pri_address: [email_addr]
        }
        expected_result = [(dn, dn_info)]
        acc = SpokeEmailAccount(self.org_name, user_id)
        result = acc.create(email_addr)['data']
        self.assertEqual(result, expected_result)
        user.delete(first, last)
Exemple #3
0
 def test_get_missing_email_account(self):
     """Retrieve a missing email account; return empty list."""
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     email_addr = 'missing@' + self.email_dom
     result = acc.get(email_addr)['data']
     expected_result = []
     self.assertEqual(result, expected_result)
Exemple #4
0
 def test_get_missing_email_account(self):
     """Retrieve a missing email account; return empty list."""
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     email_addr = 'missing@' + self.email_dom
     result = acc.get(email_addr)['data']
     expected_result = []
     self.assertEqual(result, expected_result)
Exemple #5
0
 def tearDown(self):
     """Delete test organisation, user and email domain."""
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     acc.delete(self.email_addr)
     user = SpokeUser(self.org_name)
     user.delete(self.first, self.last)
     dom = SpokeEmailDomain(self.org_name)
     dom.delete(self.email_dom)
     org = SpokeOrg()
     org.delete(self.org_name, self.org_children)
Exemple #6
0
 def setUp(self):
     """Create test organisation, user and email domain."""
     org = SpokeOrg()
     org.create(self.org_name)
     dom = SpokeEmailDomain(self.org_name)
     dom.create(self.email_dom)
     user = SpokeUser(self.org_name)
     user.create(self.email_addr, self.first, self.last)
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     acc.create(self.email_addr)
Exemple #7
0
 def tearDown(self):
     """Delete test organisation, user and email domain."""
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     acc.delete(self.email_addr)
     user = SpokeUser(self.org_name)
     user.delete(self.first, self.last)
     dom = SpokeEmailDomain(self.org_name)
     dom.delete(self.email_dom)
     org = SpokeOrg()
     org.delete(self.org_name, self.org_children)
Exemple #8
0
 def setUp(self):
     """Create test organisation, user and email domain."""
     org = SpokeOrg()
     org.create(self.org_name)
     dom = SpokeEmailDomain(self.org_name)
     dom.create(self.email_dom)
     user = SpokeUser(self.org_name)
     user.create(self.email_addr, self.first, self.last)
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     acc.create(self.email_addr)
Exemple #9
0
 def test_delete_email_account(self):
     """Delete an email account; return empty results object."""
     first = 'delete_email'
     last = 'account_test'
     user_id = first + last
     email_addr = first + last + '@' + self.email_dom
     user = SpokeUser(self.org_name)
     user.create(email_addr, first, last)
     acc = SpokeEmailAccount(self.org_name, user_id)
     acc.create(email_addr)
     newacc = SpokeEmailAccount(self.org_name, user_id)
     self.assertTrue(newacc.delete(email_addr))
     user.delete(first, last)
Exemple #10
0
 def test_get_email_account(self):
     """Retrieve an email account; return an email account object."""
     email_addr = self.user_id + '@' + self.email_dom
     org = '%s=%s' % (self.org_attr, self.org_name)
     people = '%s=%s' % (self.container_attr, self.user_container)
     uid = '%s=%s' % (self.user_key, self.user_id)
     dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn)
     dn_info = {self.imap_enable: ['TRUE'],
                self.imap_mailbox: [self.user_id],
                self.imap_domain: [self.email_dom],
                self.imap_partition: [self.imap_partition_def],
                self.smtp_destination: [email_addr],
                self.smtp_enable: ['TRUE'],
                self.smtp_pri_address: [email_addr]
                }
     expected_result = [(dn, dn_info)]        
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     result = acc.get(self.email_addr)['data']
     self.assertEqual(result, expected_result)
Exemple #11
0
 def test_delete_missing_email_account(self):
     """Delete a missing email account; raise NotFound."""
     email_addr = 'deletemissing@' + self.email_dom
     first = 'test'
     last = 'missing'
     user_id = first + last
     user = SpokeUser(self.org_name)
     user.create(email_addr, first, last)
     acc = SpokeEmailAccount(self.org_name, user_id)
     self.assertRaises(error.NotFound, acc.delete, email_addr)
     user.delete(first, last)
Exemple #12
0
 def test_get_email_account(self):
     """Retrieve an email account; return an email account object."""
     email_addr = self.user_id + '@' + self.email_dom
     org = '%s=%s' % (self.org_attr, self.org_name)
     people = '%s=%s' % (self.container_attr, self.user_container)
     uid = '%s=%s' % (self.user_key, self.user_id)
     dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn)
     dn_info = {
         self.imap_enable: ['TRUE'],
         self.imap_mailbox: [self.user_id],
         self.imap_domain: [self.email_dom],
         self.imap_partition: [self.imap_partition_def],
         self.smtp_destination: [email_addr],
         self.smtp_enable: ['TRUE'],
         self.smtp_pri_address: [email_addr]
     }
     expected_result = [(dn, dn_info)]
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     result = acc.get(self.email_addr)['data']
     self.assertEqual(result, expected_result)
Exemple #13
0
 def test_delete_email_account(self):
     """Delete an email account; return empty results object."""
     first = 'delete_email'
     last = 'account_test'
     user_id = first + last
     email_addr = first + last + '@' + self.email_dom
     user = SpokeUser(self.org_name)
     user.create(email_addr, first, last)
     acc = SpokeEmailAccount(self.org_name, user_id)
     acc.create(email_addr)
     newacc = SpokeEmailAccount(self.org_name, user_id)
     self.assertTrue(newacc.delete(email_addr))
     user.delete(first, last)
Exemple #14
0
 def test_invalid_email_account_input(self):
     """Input invalid email account; raise InputError."""
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     email_addr = '*@domain.loc'
     self.assertRaises(error.InputError, acc.get, email_addr)
Exemple #15
0
 def test_create_email_account_twice(self):
     """Create an email account twice; raise AlreadyExists."""
     email_addr = 'testcreatetwins@' + self.email_dom
     acc = SpokeEmailAccount(self.org_name, self.user_id)
     self.assertRaises(error.AlreadyExists, acc.create, email_addr)