Example #1
0
 def test_get_missing_email_address(self):
     """Retrieve a missing email address; return empty results object."""
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     email_addr = 'missing@' + self.email_dom
     result = addr.get(email_addr)['data']
     expected_result = []
     self.assertEqual(result, expected_result)
Example #2
0
 def test_get_missing_email_address(self):
     """Retrieve a missing email address; return empty results object."""
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     email_addr = 'missing@' + self.email_dom
     result = addr.get(email_addr)['data']
     expected_result = []
     self.assertEqual(result, expected_result)
Example #3
0
 def test_create_email_address(self):
     """Create email address; return result."""
     email_addr = 'testcreate@' + self.email_dom
     org = 'o=%s' % (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.smtp_address: [email_addr]}
     expected_result = [(dn, dn_info)]
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     result = addr.create(email_addr)['data']
     self.assertEqual(result, expected_result)
Example #4
0
 def test_create_email_address(self):
     """Create email address; return result."""
     email_addr = 'testcreate@' + self.email_dom
     org = 'o=%s' % (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.smtp_address: [email_addr]}
     expected_result = [(dn, dn_info)]        
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     result = addr.create(email_addr)['data']
     self.assertEqual(result, expected_result)
Example #5
0
 def test_get_all_email_address(self):
     """Retrieve all email addresss; return an email address object."""
     email_addr = 'test_get_email_addr' + '@' + self.email_dom
     email_addr2 = 'test_get_all_email_addr' + '@' + self.email_dom
     org = 'o=%s' % (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.smtp_address: [email_addr, email_addr2]}
     expected_result = [(dn, dn_info)]
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     addr.create(email_addr)
     addr.create(email_addr2)
     result = addr.get()['data']
     self.assertEqual(result, expected_result)
Example #6
0
 def test_get_all_email_address(self):
     """Retrieve all email addresss; return an email address object."""
     email_addr = 'test_get_email_addr' + '@' + self.email_dom
     email_addr2 = 'test_get_all_email_addr' + '@' + self.email_dom
     org = 'o=%s' % (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.smtp_address: [email_addr, email_addr2]}
     expected_result = [(dn, dn_info)]        
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     addr.create(email_addr)
     addr.create(email_addr2)
     result = addr.get()['data']
     self.assertEqual(result, expected_result)
Example #7
0
 def test_invalid_email_address_input(self):
     """Input invalid email address; raise InputError."""
     email_addr = '*@domain.loc'
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     self.assertRaises(error.InputError, addr.get, email_addr)
Example #8
0
 def test_delete_missing_email_address(self):
     """Delete a missing email address; raise NotFound."""
     email_addr = 'deletemissing@' + self.email_dom
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     self.assertRaises(error.NotFound, addr.delete, email_addr)
Example #9
0
 def test_delete_email_address(self):
     """Delete an email address; return True."""
     email_addr = 'delete@' + self.email_dom
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     addr.create(email_addr)
     self.assertTrue(addr.delete(email_addr))
Example #10
0
 def test_create_email_address_twice(self):
     """Create an email address twice; raise AlreadyExists."""
     email_addr = 'testcreatetwins@' + self.email_dom
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     addr.create(email_addr)
     self.assertRaises(error.AlreadyExists, addr.create, email_addr)
Example #11
0
 def test_delete_email_address(self):
     """Delete an email address; return True."""
     email_addr = 'delete@' + self.email_dom
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     addr.create(email_addr)
     self.assertTrue(addr.delete(email_addr))
Example #12
0
 def test_create_email_address_twice(self):
     """Create an email address twice; raise AlreadyExists."""
     email_addr = 'testcreatetwins@' + self.email_dom
     addr = SpokeEmailAddress(self.org_name, self.user_id)
     addr.create(email_addr)
     self.assertRaises(error.AlreadyExists, addr.create, email_addr)