-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from oasiswork/identity
Add CRUD for Identity
- Loading branch information
Showing
3 changed files
with
142 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,24 +100,49 @@ def testGetAPreference(self): | |
self.assertIsInstance(pref, dict) | ||
self.assertEqual(pref['name'], 'zimbraPrefMailFlashTitle') | ||
|
||
def testGetIdentities(self): | ||
identities = self.zc.request('GetIdentities') | ||
|
||
# only one | ||
self.assertIsInstance(identities['identity'], dict) | ||
|
||
def modifyIdentity(self): | ||
self.zc.request('ModifyIdentity', {'identity': { | ||
'name': 'DEFAULT', | ||
'a': {'name': 'zimbraPrefSaveToSent', '_content': 'FALSE'} | ||
}}) | ||
|
||
self.zc.request('ModifyIdentity', {'identity': { | ||
'name': 'DEFAULT', | ||
'a': {'name': 'zimbraPrefSaveToSent', '_content': 'TRUE'} | ||
}}) | ||
|
||
# just checks that it succeeds | ||
def testCreateGetModifyDeleteIdentity(self): | ||
# Create | ||
i = self.zc.create_identity(name='test-identity', attrs=[{ | ||
'name': 'zimbraPrefWhenInFoldersEnabled', | ||
'_content': 'TRUE' | ||
}]) | ||
|
||
# Get | ||
get_i = self.zc.get_identities(identity='test-identity')[0] | ||
# Verify create and get | ||
self.assertEqual(i, get_i) | ||
|
||
# Modify 1 | ||
from_addr = '[email protected]' | ||
|
||
i = self.zc.modify_identity( | ||
identity='test-identity', zimbraPrefFromAddress=from_addr) | ||
self.assertEqual(i._a_tags['zimbraPrefFromAddress'], from_addr) | ||
|
||
# Modify 2 | ||
# clean (needed with use of zobjects.Identity to avoid illegal | ||
# multivalue attribute) | ||
i._full_data['a'].remove({ | ||
'name': 'zimbraPrefFromAddress', | ||
'_content': from_addr}) | ||
from_addr = '[email protected]' | ||
i._full_data['a'].append({ | ||
'name': 'zimbraPrefFromAddress', | ||
'_content': from_addr}) | ||
mod_i = self.zc.modify_identity(i) | ||
self.assertEqual(mod_i._a_tags['zimbraPrefFromAddress'], from_addr) | ||
|
||
# Delete 1 | ||
self.zc.delete_identity(mod_i) | ||
|
||
self.assertEqual(self.zc.get_identities(identity=mod_i), []) | ||
|
||
# Delete 2 | ||
i = self.zc.create_identity(name='test-identity', attrs={ | ||
'zimbraPrefWhenInFoldersEnabled': 'TRUE'}) | ||
self.zc.delete_identity(identity='test-identity') | ||
|
||
self.assertEqual(self.zc.get_identities(i), []) | ||
|
||
def testAddRemoveGetBlackWhiteLists(self): | ||
addr = '[email protected]' | ||
|
@@ -338,29 +363,6 @@ def test_get_identities(self): | |
self.assertEqual(identities[0].name, 'DEFAULT') | ||
self.assertTrue(utils.is_zuuid(identities[0]['zimbraPrefIdentityId'])) | ||
|
||
def test_modify_identity(self): | ||
test_attr = 'zimbraPrefForwardReplyPrefixChar' | ||
|
||
# First get the default identity id | ||
def_identity = self.zc.get_identities()[0] | ||
|
||
initial_attrval = def_identity[test_attr] | ||
if initial_attrval == '>': | ||
new_attrval = '|' | ||
else: | ||
new_attrval = '>' | ||
|
||
i = Identity(id=def_identity.id) | ||
i[test_attr] = new_attrval | ||
self.zc.modify_identity(i) | ||
|
||
modified_i = self.zc.get_identities()[0] | ||
self.assertEqual(modified_i[test_attr], new_attrval) | ||
|
||
# Revert it back | ||
i[test_attr] = initial_attrval | ||
self.zc.modify_identity(i) | ||
|
||
def test_account_get_logged_in_by(self): | ||
admin_zc = ZimbraAdminClient(TEST_CONF['host'], | ||
TEST_CONF['admin_port']) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters