Search in sources :

Example 6 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestDelegatedDL method distributionListActionSetBadOwners.

@Test
@Bug(bug = 72791)
public void distributionListActionSetBadOwners() throws Exception {
    String GROUP_NAME = getAddress(genGroupNameLocalPart());
    Group group = createGroupAndAddOwner(GROUP_NAME);
    Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
    Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
    Account owner3 = provUtil.createAccount(genAcctNameLocalPart("3"), domain);
    SoapTransport transport = authUser(USER_OWNER);
    // 
    // setOwners: some good owners an a bogus owner (not a user)
    // 
    DistributionListAction action = new DistributionListAction(Operation.setOwners);
    DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, USER_OWNER));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner3.getName()));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, "bogus@bogus.com"));
    String errorCode = null;
    try {
        DistributionListActionResponse resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.NO_SUCH_ACCOUNT, errorCode);
    // 
    // verify owners are NOT replaced
    // 
    GetDistributionListRequest getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
    GetDistributionListResponse getDLResp = invokeJaxb(transport, getDLReq);
    DistributionListInfo dlInfo = getDLResp.getDl();
    List<? extends DistributionListGranteeInfoInterface> owners = dlInfo.getOwners();
    Set<String> ownerNames = Sets.newHashSet();
    for (DistributionListGranteeInfoInterface owner : owners) {
        if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
            ownerNames.add(owner.getName());
        }
    }
    assertEquals(1, owners.size());
    Verify.verifyEquals(Sets.newHashSet(USER_OWNER), ownerNames);
}
Also used : GetDistributionListResponse(com.zimbra.soap.account.message.GetDistributionListResponse) Group(com.zimbra.cs.account.Group) Account(com.zimbra.cs.account.Account) DistributionListGranteeInfoInterface(com.zimbra.soap.base.DistributionListGranteeInfoInterface) DistributionListInfo(com.zimbra.soap.account.type.DistributionListInfo) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) GetDistributionListRequest(com.zimbra.soap.account.message.GetDistributionListRequest) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) DistributionListGranteeSelector(com.zimbra.soap.account.type.DistributionListGranteeSelector) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 7 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestDelegatedDL method distributionListActionManipulateOwnerRight.

/*
     * verify owner right can never be altered directly, all modification on
     * owners must go through addOwners/remvoeOwners/setOwners operations
     */
@Test
public void distributionListActionManipulateOwnerRight() throws Exception {
    String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
    Group group = createGroupAndAddOwner(GROUP_NAME);
    String right = Group.GroupOwner.GROUP_OWNER_RIGHT.getName();
    Account grantee = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
    SoapTransport transport = authUser(USER_OWNER);
    // 
    // grantRights
    // 
    DistributionListAction action = new DistributionListAction(Operation.grantRights);
    DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    DistributionListRightSpec dlRight = new DistributionListRightSpec(right);
    dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
    action.addRight(dlRight);
    DistributionListActionResponse resp;
    boolean caughtException = false;
    try {
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
            caughtException = true;
        }
    }
    assertTrue(caughtException);
    // 
    // revokeRights
    // 
    action = new DistributionListAction(Operation.revokeRights);
    req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    dlRight = new DistributionListRightSpec(right);
    dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
    action.addRight(dlRight);
    caughtException = false;
    try {
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
            caughtException = true;
        }
    }
    assertTrue(caughtException);
    // 
    // setRights
    // 
    action = new DistributionListAction(Operation.setRights);
    req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    dlRight = new DistributionListRightSpec(right);
    dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
    action.addRight(dlRight);
    caughtException = false;
    try {
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
            caughtException = true;
        }
    }
    assertTrue(caughtException);
}
Also used : Group(com.zimbra.cs.account.Group) Account(com.zimbra.cs.account.Account) DistributionListGranteeSelector(com.zimbra.soap.account.type.DistributionListGranteeSelector) 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) DistributionListRightSpec(com.zimbra.soap.account.type.DistributionListRightSpec) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) Test(org.junit.Test)

Example 8 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestDelegatedDL method distributionListActionSetOwners.

@Test
public void distributionListActionSetOwners() throws Exception {
    String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
    Group group = createGroupAndAddOwner(GROUP_NAME);
    Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
    Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
    Account owner3 = provUtil.createAccount(genAcctNameLocalPart("3"), domain);
    SoapTransport transport = authUser(USER_OWNER);
    // 
    // setOwners
    // 
    DistributionListAction action = new DistributionListAction(Operation.setOwners);
    DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, USER_OWNER));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, owner3.getName()));
    DistributionListActionResponse resp = invokeJaxb(transport, req);
    // 
    // verify owners are replaced
    // 
    GetDistributionListRequest getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
    GetDistributionListResponse getDLResp = invokeJaxb(transport, getDLReq);
    DistributionListInfo dlInfo = getDLResp.getDl();
    List<? extends DistributionListGranteeInfoInterface> owners = dlInfo.getOwners();
    Set<String> ownerNames = Sets.newHashSet();
    for (DistributionListGranteeInfoInterface owner : owners) {
        if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
            ownerNames.add(owner.getName());
        }
    }
    assertEquals(4, owners.size());
    Verify.verifyEquals(Sets.newHashSet(USER_OWNER, owner1.getName(), owner2.getName(), owner3.getName()), ownerNames);
    /*
         * test invalid grantee type for owner
         */
    action = new DistributionListAction(Operation.setOwners);
    req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, "user@external.com"));
    String errCode = null;
    try {
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errCode = e.getCode();
    }
    assertEquals(ServiceException.INVALID_REQUEST, errCode);
    // remove all owners
    action = new DistributionListAction(Operation.setOwners);
    req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
    resp = invokeJaxb(transport, req);
    getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
    getDLResp = invokeJaxb(transport, getDLReq);
    dlInfo = getDLResp.getDl();
    owners = dlInfo.getOwners();
    assertEquals(0, owners.size());
}
Also used : GetDistributionListResponse(com.zimbra.soap.account.message.GetDistributionListResponse) Group(com.zimbra.cs.account.Group) Account(com.zimbra.cs.account.Account) DistributionListGranteeInfoInterface(com.zimbra.soap.base.DistributionListGranteeInfoInterface) DistributionListInfo(com.zimbra.soap.account.type.DistributionListInfo) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) GetDistributionListRequest(com.zimbra.soap.account.message.GetDistributionListRequest) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) DistributionListGranteeSelector(com.zimbra.soap.account.type.DistributionListGranteeSelector) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 9 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestExpandGroupInfo method getMsg.

@Test
public void getMsg() throws Exception {
    String SUBJECT = getTestName();
    String msgId = createAppt(acct, group.getName(), SUBJECT, "blah");
    SoapTransport transport = authUser(acct.getName());
    MsgSpec msgSpec = new MsgSpec(msgId);
    msgSpec.setNeedCanExpand(Boolean.TRUE);
    GetMsgRequest req = new GetMsgRequest(msgSpec);
    GetMsgResponse resp = invokeJaxb(transport, req);
    MsgWithGroupInfo msg = resp.getMsg();
    InviteWithGroupInfo invite = msg.getInvite();
    List<InviteComponentWithGroupInfo> invComps = invite.getInviteComponents();
    for (InviteComponentWithGroupInfo invComp : invComps) {
        List<CalendarAttendeeWithGroupInfo> attendees = invComp.getAttendees();
        for (CalendarAttendeeWithGroupInfo attendee : attendees) {
            Boolean isGroup = attendee.getGroup();
            Boolean canExpandGroupMembers = attendee.getCanExpandGroupMembers();
            assertTrue(isGroup);
            assertTrue(canExpandGroupMembers);
        }
    }
}
Also used : CalendarAttendeeWithGroupInfo(com.zimbra.soap.mail.type.CalendarAttendeeWithGroupInfo) MsgWithGroupInfo(com.zimbra.soap.mail.type.MsgWithGroupInfo) GetMsgRequest(com.zimbra.soap.mail.message.GetMsgRequest) GetMsgResponse(com.zimbra.soap.mail.message.GetMsgResponse) InviteWithGroupInfo(com.zimbra.soap.mail.type.InviteWithGroupInfo) MsgSpec(com.zimbra.soap.mail.type.MsgSpec) SoapTransport(com.zimbra.common.soap.SoapTransport) InviteComponentWithGroupInfo(com.zimbra.soap.mail.type.InviteComponentWithGroupInfo) Test(org.junit.Test)

Example 10 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestExpandGroupInfo method search.

@Test
public void search() throws Exception {
    // send a to acct, recipient is a group
    String SUBJECT = getTestName();
    sendMsg(acct, group.getName(), SUBJECT, "blah");
    SoapTransport transport = authUser(acct.getName());
    SearchRequest searchReq = new SearchRequest();
    searchReq.setSearchTypes(MailItem.Type.MESSAGE.toString());
    searchReq.setQuery(String.format("in:inbox and subject:%s", SUBJECT));
    searchReq.setFetch(SearchParams.ExpandResults.ALL.toString());
    SearchResponse searchResp = invokeJaxb(transport, searchReq);
    List<SearchHit> searchHits = searchResp.getSearchHits();
    assertEquals(1, searchHits.size());
    verifyGroupInfo((MessageHitInfo) searchHits.get(0), null, null);
    /*
         * search again with needExp
         */
    searchReq.setNeedCanExpand(Boolean.TRUE);
    searchResp = invokeJaxb(transport, searchReq);
    searchHits = searchResp.getSearchHits();
    assertEquals(1, searchHits.size());
    verifyGroupInfo((MessageHitInfo) searchHits.get(0), Boolean.TRUE, Boolean.TRUE);
}
Also used : SearchRequest(com.zimbra.soap.mail.message.SearchRequest) SearchHit(com.zimbra.soap.type.SearchHit) SoapTransport(com.zimbra.common.soap.SoapTransport) SearchResponse(com.zimbra.soap.mail.message.SearchResponse) Test(org.junit.Test)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)89 Test (org.junit.Test)69 Account (com.zimbra.cs.account.Account)38 Element (com.zimbra.common.soap.Element)24 Group (com.zimbra.cs.account.Group)23 ServiceException (com.zimbra.common.service.ServiceException)18 SoapFaultException (com.zimbra.common.soap.SoapFaultException)16 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)12 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)12 AccountServiceException (com.zimbra.cs.account.AccountServiceException)11 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)11 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)10 ArrayList (java.util.ArrayList)10 SoapProtocol (com.zimbra.common.soap.SoapProtocol)9 Bug (com.zimbra.qa.QA.Bug)9 CreateSignatureRequest (com.zimbra.soap.account.message.CreateSignatureRequest)9 Signature (com.zimbra.soap.account.type.Signature)9 Domain (com.zimbra.cs.account.Domain)8 GetDistributionListRequest (com.zimbra.soap.account.message.GetDistributionListRequest)8 GetDistributionListResponse (com.zimbra.soap.account.message.GetDistributionListResponse)6