Search in sources :

Example 1 with DistributionListRightInfo

use of com.zimbra.soap.account.type.DistributionListRightInfo in project zm-mailbox by Zimbra.

the class TestDelegatedDL method getDistributionListRights.

/*
     * verify rights are returned
     */
@Test
public void getDistributionListRights() throws Exception {
    String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
    Group group = createGroupAndAddOwner(GROUP_NAME);
    String right1 = Right.RT_sendToDistList;
    String right2 = Right.RT_viewDistList;
    Account grantee1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
    Account grantee2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
    SoapTransport transport = authUser(USER_OWNER);
    // 
    // grantRights
    // 
    DistributionListAction action = new DistributionListAction(Operation.grantRights);
    DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    DistributionListRightSpec dlRight1 = new DistributionListRightSpec(right1);
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee1.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee2.getName()));
    DistributionListRightSpec dlRight2 = new DistributionListRightSpec(right2);
    dlRight2.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
    action.addRight(dlRight1);
    action.addRight(dlRight2);
    DistributionListActionResponse resp = invokeJaxb(transport, req);
    /*
         * verify rights are returned
         */
    GetDistributionListRequest getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.FALSE, right1 + "," + right2);
    GetDistributionListResponse getDLResp = invokeJaxb(transport, getDLReq);
    DistributionListInfo dlInfo = getDLResp.getDl();
    List<? extends DistributionListRightInfo> rights = dlInfo.getRights();
    Set<String> right1GranteeNames = Sets.newHashSet();
    Set<String> right2GranteeNames = Sets.newHashSet();
    for (DistributionListRightInfo rightInfo : rights) {
        String right = rightInfo.getRight();
        List<DistributionListGranteeInfo> grantees = rightInfo.getGrantees();
        if (right1.equals(right)) {
            for (DistributionListGranteeInfo grantee : grantees) {
                right1GranteeNames.add(Verify.makeResultStr(grantee.getType().name(), grantee.getName()));
            }
        } else if (right2.equals(right)) {
            for (DistributionListGranteeInfo grantee : grantees) {
                right2GranteeNames.add(Verify.makeResultStr(grantee.getType().name(), grantee.getName()));
            }
        }
    }
    Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee1.getName()), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee2.getName())), right1GranteeNames);
    Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(GranteeType.GT_AUTHUSER.getCode(), "null")), right2GranteeNames);
}
Also used : GetDistributionListResponse(com.zimbra.soap.account.message.GetDistributionListResponse) Group(com.zimbra.cs.account.Group) Account(com.zimbra.cs.account.Account) DistributionListInfo(com.zimbra.soap.account.type.DistributionListInfo) DistributionListGranteeInfo(com.zimbra.soap.account.type.DistributionListGranteeInfo) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) GetDistributionListRequest(com.zimbra.soap.account.message.GetDistributionListRequest) DistributionListRightInfo(com.zimbra.soap.account.type.DistributionListRightInfo) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) DistributionListGranteeSelector(com.zimbra.soap.account.type.DistributionListGranteeSelector) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) DistributionListRightSpec(com.zimbra.soap.account.type.DistributionListRightSpec) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)1 Account (com.zimbra.cs.account.Account)1 Group (com.zimbra.cs.account.Group)1 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)1 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)1 GetDistributionListRequest (com.zimbra.soap.account.message.GetDistributionListRequest)1 GetDistributionListResponse (com.zimbra.soap.account.message.GetDistributionListResponse)1 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)1 DistributionListGranteeInfo (com.zimbra.soap.account.type.DistributionListGranteeInfo)1 DistributionListGranteeSelector (com.zimbra.soap.account.type.DistributionListGranteeSelector)1 DistributionListInfo (com.zimbra.soap.account.type.DistributionListInfo)1 DistributionListRightInfo (com.zimbra.soap.account.type.DistributionListRightInfo)1 DistributionListRightSpec (com.zimbra.soap.account.type.DistributionListRightSpec)1 Test (org.junit.Test)1