Search in sources :

Example 11 with DistributionListActionRequest

use of com.zimbra.soap.account.message.DistributionListActionRequest in project zm-mailbox by Zimbra.

the class TestDelegatedDL method noHomeServerZimbraAccount.

/*
     * Verify groups without a home server will get PROXY_ERROR for zimbraAccount
     * SOAP calls.
     */
@Test
@Bug(bug = 66412)
public void noHomeServerZimbraAccount() throws Exception {
    String groupName = TestUtil.getAddress(genGroupNameLocalPart(), DOMAIN_NAME);
    Group group = provUtil.createGroup(groupName, DYNAMIC);
    // remove zimbraMailHost
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraMailHost, null);
    prov.modifyAttrs(group, attrs);
    SoapTransport transport = authUser(USER_OWNER);
    /*
         * GetDistributionList
         */
    GetDistributionListRequest getDLreq = new GetDistributionListRequest(DistributionListSelector.fromName(groupName), Boolean.TRUE);
    verifyCaughtProxyError(transport, getDLreq);
    /*
         * DistributionListAction
         */
    DistributionListActionRequest DLActionReq = new DistributionListActionRequest(DistributionListSelector.fromName(groupName), new DistributionListAction(Operation.addMembers));
    verifyCaughtProxyError(transport, DLActionReq);
    /*
         * SubscribeDistributionList
         */
    SubscribeDistributionListRequest subsDLReq = new SubscribeDistributionListRequest(DistributionListSelector.fromName(groupName), DistributionListSubscribeOp.subscribe);
    verifyCaughtProxyError(transport, subsDLReq);
    provUtil.deleteGroup(group);
}
Also used : Group(com.zimbra.cs.account.Group) SubscribeDistributionListRequest(com.zimbra.soap.account.message.SubscribeDistributionListRequest) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) GetDistributionListRequest(com.zimbra.soap.account.message.GetDistributionListRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 12 with DistributionListActionRequest

use of com.zimbra.soap.account.message.DistributionListActionRequest in project zm-mailbox by Zimbra.

the class TestDelegatedDL method removeOwner.

private static void removeOwner(SoapTransport transport, String groupName, String ownerName) throws Exception {
    DistributionListAction action = new DistributionListAction(Operation.removeOwners);
    DistributionListActionRequest actionReq = new DistributionListActionRequest(DistributionListSelector.fromName(groupName), action);
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, ownerName));
    DistributionListActionResponse actionResp = invokeJaxb(transport, actionReq);
}
Also used : DistributionListGranteeSelector(com.zimbra.soap.account.type.DistributionListGranteeSelector) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest)

Example 13 with DistributionListActionRequest

use of com.zimbra.soap.account.message.DistributionListActionRequest in project zm-mailbox by Zimbra.

the class TestDelegatedDL method distributionListActionGrantRevokeSetRights.

@Test
public void distributionListActionGrantRevokeSetRights() 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);
    Group groupGrantee1 = provUtil.createGroup(genGroupNameLocalPart("3"), domain, DYNAMIC);
    // test grantees specified as "email" grantee type
    Account grantee3 = provUtil.createAccount(genAcctNameLocalPart("4"), domain);
    Account grantee4 = provUtil.createAccount(genAcctNameLocalPart("5"), domain);
    Group groupGrantee2 = provUtil.createGroup(genGroupNameLocalPart("6"), domain, DYNAMIC);
    String GUEST = "user@external.com";
    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()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.grp, DistributionListGranteeBy.name, groupGrantee1.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.pub, null, null));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee3.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee4.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, groupGrantee2.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, GUEST));
    DistributionListRightSpec dlRight2 = new DistributionListRightSpec(right2);
    dlRight2.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee1.getName()));
    dlRight2.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee2.getName()));
    action.addRight(dlRight1);
    action.addRight(dlRight2);
    DistributionListActionResponse resp = invokeJaxb(transport, req);
    //
    // verify rights are granted
    //
    RightCommand.Grants grants = prov.getGrants(TargetType.dl.name(), TargetBy.id, group.getId(), null, null, null, true);
    Set<String> right1GranteeNames = Sets.newHashSet();
    Set<String> right2GranteeNames = Sets.newHashSet();
    for (RightCommand.ACE ace : grants.getACEs()) {
        String right = ace.right();
        if (right1.equals(right)) {
            right1GranteeNames.add(Verify.makeResultStr(ace.granteeType(), ace.granteeName()));
        } else if (right2.equals(right)) {
            right2GranteeNames.add(Verify.makeResultStr(ace.granteeType(), ace.granteeName()));
        }
    }
    Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee1.getName()), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee2.getName()), Verify.makeResultStr(GranteeType.GT_GROUP.getCode(), groupGrantee1.getName()), Verify.makeResultStr(GranteeType.GT_AUTHUSER.getCode(), ""), Verify.makeResultStr(GranteeType.GT_PUBLIC.getCode(), ""), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee3.getName()), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee4.getName()), Verify.makeResultStr(GranteeType.GT_GROUP.getCode(), groupGrantee2.getName()), Verify.makeResultStr(GranteeType.GT_GUEST.getCode(), GUEST)), right1GranteeNames);
    Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee1.getName()), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee2.getName())), right2GranteeNames);
    //
    // setRights
    //
    action = new DistributionListAction(Operation.setRights);
    req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    dlRight1 = new DistributionListRightSpec(right1);
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee3.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee4.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, groupGrantee2.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, GUEST));
    dlRight2 = new DistributionListRightSpec(right2);
    // don't add any grantee, this should revoke all grants for right2
    action.addRight(dlRight1);
    action.addRight(dlRight2);
    resp = invokeJaxb(transport, req);
    //
    // verify rights are set
    //
    grants = prov.getGrants(TargetType.dl.name(), TargetBy.id, group.getId(), null, null, null, true);
    right1GranteeNames = Sets.newHashSet();
    right2GranteeNames = Sets.newHashSet();
    for (RightCommand.ACE ace : grants.getACEs()) {
        String right = ace.right();
        if (right1.equals(right)) {
            right1GranteeNames.add(Verify.makeResultStr(ace.granteeType(), ace.granteeName()));
        } else if (right2.equals(right)) {
            right2GranteeNames.add(Verify.makeResultStr(ace.granteeType(), ace.granteeName()));
        }
    }
    Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(GranteeType.GT_AUTHUSER.getCode(), ""), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee3.getName()), Verify.makeResultStr(GranteeType.GT_USER.getCode(), grantee4.getName()), Verify.makeResultStr(GranteeType.GT_GROUP.getCode(), groupGrantee2.getName()), Verify.makeResultStr(GranteeType.GT_GUEST.getCode(), GUEST)), right1GranteeNames);
    assertEquals(0, right2GranteeNames.size());
    //
    // revokeRights
    //
    action = new DistributionListAction(Operation.revokeRights);
    req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    dlRight1 = new DistributionListRightSpec(right1);
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee3.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee4.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, groupGrantee2.getName()));
    dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, GUEST));
    action.addRight(dlRight1);
    resp = invokeJaxb(transport, req);
    //
    // verify all rights are revoked
    //
    grants = prov.getGrants(TargetType.dl.name(), TargetBy.id, group.getId(), null, null, null, true);
    right1GranteeNames = Sets.newHashSet();
    right2GranteeNames = Sets.newHashSet();
    for (RightCommand.ACE ace : grants.getACEs()) {
        String right = ace.right();
        if (right1.equals(right)) {
            right1GranteeNames.add(ace.granteeName());
        } else if (right2.equals(right)) {
            right2GranteeNames.add(ace.granteeName());
        }
    }
    assertEquals(0, right1GranteeNames.size());
    assertEquals(0, right2GranteeNames.size());
}
Also used : Group(com.zimbra.cs.account.Group) Account(com.zimbra.cs.account.Account) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) DistributionListGranteeSelector(com.zimbra.soap.account.type.DistributionListGranteeSelector) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) DistributionListRightSpec(com.zimbra.soap.account.type.DistributionListRightSpec) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 14 with DistributionListActionRequest

use of com.zimbra.soap.account.message.DistributionListActionRequest in project zm-mailbox by Zimbra.

the class TestDelegatedDL method distributionListActionDelete.

@Test
public void distributionListActionDelete() throws Exception {
    // create a group for the delete test
    String NAME = getAddress(genGroupNameLocalPart());
    Group group = createGroupAndAddOwner(NAME);
    SoapTransport transport = authUser(USER_OWNER);
    DistributionListAction action = new DistributionListAction(Operation.delete);
    DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(NAME), action);
    DistributionListActionResponse resp;
    String errorCode = null;
    try {
        // only people with create right and owner right can delete
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(ServiceException.PERM_DENIED, errorCode);
    /*
         * auth as creator and try again, should still fail
         */
    transport = authUser(USER_CREATOR);
    errorCode = null;
    try {
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(ServiceException.PERM_DENIED, errorCode);
    // make the creator an owner
    transport = authUser(USER_OWNER);
    addOwner(transport, group.getName(), USER_CREATOR);
    // now try delete as the creator (also an owner now), should succeed
    transport = authUser(USER_CREATOR);
    resp = invokeJaxb(transport, req);
    group = prov.getGroup(Key.DistributionListBy.name, NAME);
    assertNull(null);
}
Also used : Group(com.zimbra.cs.account.Group) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) Test(org.junit.Test)

Aggregations

DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)14 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)14 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)13 SoapTransport (com.zimbra.common.soap.SoapTransport)12 Group (com.zimbra.cs.account.Group)12 Test (org.junit.Test)12 Account (com.zimbra.cs.account.Account)9 DistributionListGranteeSelector (com.zimbra.soap.account.type.DistributionListGranteeSelector)8 ServiceException (com.zimbra.common.service.ServiceException)5 AccountServiceException (com.zimbra.cs.account.AccountServiceException)5 GetDistributionListRequest (com.zimbra.soap.account.message.GetDistributionListRequest)5 GetDistributionListResponse (com.zimbra.soap.account.message.GetDistributionListResponse)4 DistributionListInfo (com.zimbra.soap.account.type.DistributionListInfo)4 DistributionListRightSpec (com.zimbra.soap.account.type.DistributionListRightSpec)3 DistributionListGranteeInfoInterface (com.zimbra.soap.base.DistributionListGranteeInfoInterface)3 Bug (com.zimbra.qa.QA.Bug)2 Domain (com.zimbra.cs.account.Domain)1 RightCommand (com.zimbra.cs.account.accesscontrol.RightCommand)1 SubscribeDistributionListRequest (com.zimbra.soap.account.message.SubscribeDistributionListRequest)1 DistributionListGranteeInfo (com.zimbra.soap.account.type.DistributionListGranteeInfo)1