use of com.zimbra.soap.account.type.DiscoverRightsInfo in project zm-mailbox by Zimbra.
the class TestGetInfo method discoverRights.
@Test
public void discoverRights() throws Exception {
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
Group group = provUtil.createGroup(genGroupNameLocalPart(), domain, false);
prov.grantRight(TargetType.domain.getCode(), TargetBy.name, domain.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, User.R_createDistList.getName(), null);
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, User.R_sendToDistList.getName(), null);
SoapTransport transport = authUser(acct.getName());
GetInfoRequest req = new GetInfoRequest();
req.addRight(User.R_createDistList.getName());
req.addRight(User.R_sendToDistList.getName());
GetInfoResponse resp = invokeJaxb(transport, req);
List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
Set<String> result = Sets.newHashSet();
for (DiscoverRightsInfo rightInfo : rightsInfo) {
String right = rightInfo.getRight();
List<DiscoverRightsTarget> targets = rightInfo.getTargets();
for (DiscoverRightsTarget target : targets) {
String id = target.getId();
String name = target.getName();
String type = target.getType().toString();
result.add(Verify.makeResultStr(right, id, name, type));
}
}
Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(User.R_createDistList.getName(), domain.getId(), domain.getName(), TargetType.domain.getCode()), Verify.makeResultStr(User.R_sendToDistList.getName(), group.getId(), group.getName(), TargetType.dl.getCode())), result);
}
use of com.zimbra.soap.account.type.DiscoverRightsInfo in project zm-mailbox by Zimbra.
the class TestDiscoverRights method displayName.
/*
* verify display name is returned in DiscoverRights and discovered targets
* are sorted by displayName
*/
@Test
@Bug(bug = 68225)
public void displayName() throws Exception {
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
String GROUP_1_NAME = getAddress(genGroupNameLocalPart("1"));
String GROUP_1_DISPLAY_NAME = "third";
String GROUP_2_NAME = getAddress(genGroupNameLocalPart("2"));
String GROUP_2_DISPLAY_NAME = "first";
String GROUP_3_NAME = getAddress(genGroupNameLocalPart("3"));
String GROUP_3_DISPLAY_NAME = "first";
Group group1 = provUtil.createGroup(GROUP_1_NAME, Collections.singletonMap(Provisioning.A_displayName, (Object) GROUP_1_DISPLAY_NAME), false);
Group group2 = provUtil.createGroup(GROUP_2_NAME, Collections.singletonMap(Provisioning.A_displayName, (Object) GROUP_2_DISPLAY_NAME), false);
Group group3 = provUtil.createGroup(GROUP_3_NAME, Collections.singletonMap(Provisioning.A_displayName, (Object) GROUP_3_DISPLAY_NAME), false);
String RIGHT_NAME = User.R_ownDistList.getName();
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group1.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, RIGHT_NAME, null);
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group2.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, RIGHT_NAME, null);
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group3.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, RIGHT_NAME, null);
SoapTransport transport = authUser(acct.getName());
DiscoverRightsRequest req = new DiscoverRightsRequest(Collections.singletonList(RIGHT_NAME));
DiscoverRightsResponse resp = invokeJaxb(transport, req);
List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
assertEquals(1, rightsInfo.size());
List<String> result = Lists.newArrayList();
for (DiscoverRightsInfo rightInfo : rightsInfo) {
List<DiscoverRightsTarget> targets = rightInfo.getTargets();
for (DiscoverRightsTarget target : targets) {
String id = target.getId();
String name = target.getName();
String displayName = target.getDisplayName();
result.add(Verify.makeResultStr(id, name, displayName));
}
}
// result should be sorted by displayName.
// If displayName are the same, sorted by entry.getLabel()
Verify.verifyEquals(Lists.newArrayList(Verify.makeResultStr(group2.getId(), group2.getName(), group2.getDisplayName()), Verify.makeResultStr(group3.getId(), group3.getName(), group3.getDisplayName()), Verify.makeResultStr(group1.getId(), group1.getName(), group1.getDisplayName())), result);
}
use of com.zimbra.soap.account.type.DiscoverRightsInfo in project zm-mailbox by Zimbra.
the class TestDiscoverRights method granteeAll.
@Test
public void granteeAll() throws Exception {
Domain testDomain = provUtil.createDomain(genDomainName(domain.getName()));
Account acct = provUtil.createAccount(genAcctNameLocalPart(), testDomain);
String RIGHT_NAME = Right.RT_createDistList;
prov.grantRight(TargetType.domain.getCode(), TargetBy.name, testDomain.getName(), GranteeType.GT_AUTHUSER.getCode(), null, null, null, RIGHT_NAME, null);
SoapTransport transport = authUser(acct.getName());
DiscoverRightsRequest req = new DiscoverRightsRequest(Collections.singletonList(RIGHT_NAME));
DiscoverRightsResponse resp = invokeJaxb(transport, req);
List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
List<String> result = Lists.newArrayList();
for (DiscoverRightsInfo rightInfo : rightsInfo) {
List<DiscoverRightsTarget> targets = rightInfo.getTargets();
for (DiscoverRightsTarget target : targets) {
String id = target.getId();
String name = target.getName();
result.add(Verify.makeResultStr(id, name));
}
}
Verify.verifyEquals(Lists.newArrayList(Verify.makeResultStr(testDomain.getId(), testDomain.getName())), result);
provUtil.deleteAccount(acct);
provUtil.deleteDomain(testDomain);
}
Aggregations