use of com.zimbra.cs.account.accesscontrol.ZimbraACE in project zm-mailbox by Zimbra.
the class TestACLAttrRight method grantRight.
/*
* TODO: following methods (grantRight and verify) copied from legacy
* com.zimbra.qa.unittest.TestACL.
* Move to ACLTestUtil if used in other classes as we continue to renovate ACL
* unit tests.
*
*
* utility methods to grant/revoke right
*
* To simulate how grants are done in the real server/zmprov, we first call TargetType.lookupTarget to
* "look for" the taret, then use the returned entry instead of giving the target entry passed in
* directly to RightUtil.
*
* This is for testing user rights, which goes to RightUtil directly (i.e. not through RightCommand)
*
*/
private List<ZimbraACE> grantRight(TargetType targetType, Entry target, Set<ZimbraACE> aces) throws ServiceException {
/*
* make sure all rights are user right, tests written earlier could still be using
* this to grant
*/
for (ZimbraACE ace : aces) {
assertTrue(ace.getRight().isUserRight());
}
Entry targetEntry;
if (target instanceof Zimlet) {
// must be by name
String targetName = ((Zimlet) target).getName();
targetEntry = TargetType.lookupTarget(prov, targetType, TargetBy.name, targetName);
} else {
String targetId = (target instanceof NamedEntry) ? ((NamedEntry) target).getId() : null;
targetEntry = TargetType.lookupTarget(prov, targetType, TargetBy.id, targetId);
}
return ACLUtil.grantRight(prov, targetEntry, aces);
}
Aggregations