Search in sources :

Example 1 with DiscoverRightsResponse

use of com.zimbra.soap.account.message.DiscoverRightsResponse 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);
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) DiscoverRightsRequest(com.zimbra.soap.account.message.DiscoverRightsRequest) DiscoverRightsInfo(com.zimbra.soap.account.type.DiscoverRightsInfo) DiscoverRightsResponse(com.zimbra.soap.account.message.DiscoverRightsResponse) DiscoverRightsTarget(com.zimbra.soap.account.type.DiscoverRightsTarget) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 2 with DiscoverRightsResponse

use of com.zimbra.soap.account.message.DiscoverRightsResponse 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);
}
Also used : Account(com.zimbra.cs.account.Account) DiscoverRightsRequest(com.zimbra.soap.account.message.DiscoverRightsRequest) DiscoverRightsInfo(com.zimbra.soap.account.type.DiscoverRightsInfo) DiscoverRightsResponse(com.zimbra.soap.account.message.DiscoverRightsResponse) DiscoverRightsTarget(com.zimbra.soap.account.type.DiscoverRightsTarget) Domain(com.zimbra.cs.account.Domain) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)2 Account (com.zimbra.cs.account.Account)2 DiscoverRightsRequest (com.zimbra.soap.account.message.DiscoverRightsRequest)2 DiscoverRightsResponse (com.zimbra.soap.account.message.DiscoverRightsResponse)2 DiscoverRightsInfo (com.zimbra.soap.account.type.DiscoverRightsInfo)2 DiscoverRightsTarget (com.zimbra.soap.account.type.DiscoverRightsTarget)2 Test (org.junit.Test)2 Domain (com.zimbra.cs.account.Domain)1 Group (com.zimbra.cs.account.Group)1 Bug (com.zimbra.qa.QA.Bug)1