Search in sources :

Example 1 with GetDistributionListMembersResponse

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

the class TestDelegatedDL method getDistributionListMembersWithGSA.

/*
     * If GAL sync account is enabled, newly created groups are not synced in the GSA yet.
     * If a GetDistributionListMembersRequest is issued before it's synced, will get
     * NO_SUCH_DISTRIBUTION_LIST exception.
     */
@Test
@Bug(bug = { 72482, 73460 })
public void getDistributionListMembersWithGSA() throws Exception {
    // setup GAL sync account
    GalTestUtil.enableGalSyncAccount(prov, domain.getName(), "galsync1");
    String GROUP_NAME = getAddress(genGroupNameLocalPart());
    // create an owner account
    Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
    Group group = createGroupAndAddOwner(GROUP_NAME, ownerAcct.getName());
    // create member accounts and add it to the group
    Account memberAcct1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
    Account memberAcct2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
    Account memberAcct3 = provUtil.createAccount(genAcctNameLocalPart("member3"), domain);
    Account memberAcct4 = provUtil.createAccount(genAcctNameLocalPart("member4"), domain);
    prov.addGroupMembers(group, new String[] { memberAcct3.getName(), memberAcct2.getName(), memberAcct1.getName() });
    // create a non-member account
    Account nonMemberAcct = provUtil.createAccount(genAcctNameLocalPart("non-member"), domain);
    /*
         * Owners should be able to see members even when the list is not in GSA yet
         */
    // auth as the owner
    SoapTransport transport = authUser(ownerAcct.getName());
    GetDistributionListMembersRequest req = new GetDistributionListMembersRequest(null, null, group.getName());
    GetDistributionListMembersResponse resp = invokeJaxb(transport, req);
    List<String> members = resp.getDlMembers();
    //make sure members are returned sorted
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
    /*
         * members should be able to see members even when the list is not in GSA yet
         */
    // auth as a member
    transport = authUser(memberAcct1.getName());
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    //make sure members are returned sorted
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
    /*
         * non-owner, non-member cannot see members when the list is not in GSA yet
         */
    transport = authUser(nonMemberAcct.getName());
    String errorCode = null;
    try {
        invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
    /*
         * re-sync the GSA, so now non-owner/non member can also see the group.
         * Too much trouble re-sync the GSA, just disable and enable again.
         */
    GalTestUtil.disableGalSyncAccount(prov, domain.getName());
    GalTestUtil.enableGalSyncAccount(prov, domain.getName(), "galsync2");
    // now non-owner/non-member can also see the group
    transport = authUser(nonMemberAcct.getName());
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    //make sure members are returned sorted
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
    // add a member
    prov.addGroupMembers(group, new String[] { memberAcct4.getName() });
    // owner can see the new member
    transport = authUser(ownerAcct.getName());
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName()), members);
    // member can see the new member
    transport = authUser(memberAcct1.getName());
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName()), members);
    // non-owner, non-member cannot see the new member yet, becasuse the change has not
    // yet synced to the GSA.
    transport = authUser(nonMemberAcct.getName());
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    //make sure members are returned sorted
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
    GalTestUtil.disableGalSyncAccount(prov, domain.getName());
    provUtil.deleteAccount(ownerAcct);
    provUtil.deleteAccount(memberAcct1);
    provUtil.deleteAccount(memberAcct2);
    provUtil.deleteAccount(memberAcct3);
    provUtil.deleteAccount(memberAcct4);
    provUtil.deleteAccount(nonMemberAcct);
    provUtil.deleteGroup(group);
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) GetDistributionListMembersResponse(com.zimbra.soap.account.message.GetDistributionListMembersResponse) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) GetDistributionListMembersRequest(com.zimbra.soap.account.message.GetDistributionListMembersRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 2 with GetDistributionListMembersResponse

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

the class JaxbToJsonTest method contentList.

/**
     * Test for "List of strings" field annotated with {@link XmlElement}.
     * Desired JSON:
     * {
     *   "more": false,
     *   "total": 23,
     *   "dlm": [
     *     {
     *       "_content": "dlmember1@no.where"
     *     },
     *     {
     *       "_content": "dlmember2@no.where"
     *     },
     *     {
     *       "_content": "dlmember3@no.where"
     *     }],
     *   "_jsns": "urn:zimbraAccount"
     * }
     */
@Test
public void contentList() throws Exception {
    Element legacyElem = JSONElement.mFactory.createElement(AccountConstants.GET_DISTRIBUTION_LIST_MEMBERS_RESPONSE);
    legacyElem.addAttribute(AccountConstants.A_MORE, false);
    legacyElem.addAttribute(AccountConstants.A_TOTAL, 23);
    legacyElem.addElement(AccountConstants.E_DLM).setText("dlmember1@no.where");
    legacyElem.addElement(AccountConstants.E_DLM).setText("dlmember2@no.where");
    legacyElem.addElement(AccountConstants.E_DLM).setText("dlmember3@no.where");
    logDebug("GetDistributionListMembersResponse JSONElement ---> prettyPrint\n%1$s", legacyElem.prettyPrint());
    // GetDistributionListMembersResponse has:
    //      @XmlElement(name=AccountConstants.E_DLM, required=false)
    //      private List<String> dlMembers = Lists.newArrayList();
    GetDistributionListMembersResponse jaxb = new GetDistributionListMembersResponse();
    jaxb.setMore(false);
    jaxb.setTotal(23);
    jaxb.addDlMember("dlmember1@no.where");
    jaxb.addDlMember("dlmember2@no.where");
    jaxb.addDlMember("dlmember3@no.where");
    Element elem = JacksonUtil.jaxbToJSONElement(jaxb, AccountConstants.GET_DISTRIBUTION_LIST_MEMBERS_RESPONSE);
    logDebug("GetDistributionListMembersResponse JSONElement from JAXB ---> prettyPrint\n%1$s", elem.prettyPrint());
    List<Element> dlMembers = elem.listElements(AccountConstants.E_DLM);
    Assert.assertEquals("Number of dlMembers", 3, dlMembers.size());
    Element dlMem3 = dlMembers.get(2);
    Assert.assertEquals("dlMember 3", "dlmember3@no.where", dlMem3.getText());
    Assert.assertEquals("total", 23, elem.getAttributeInt(AccountConstants.A_TOTAL));
    Assert.assertEquals("more", false, elem.getAttributeBool(AccountConstants.A_MORE));
    Assert.assertEquals("prettyPrint", legacyElem.prettyPrint(), elem.prettyPrint());
}
Also used : GetDistributionListMembersResponse(com.zimbra.soap.account.message.GetDistributionListMembersResponse) XmlAnyElement(javax.xml.bind.annotation.XmlAnyElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) XmlElement(javax.xml.bind.annotation.XmlElement) FilterTest(com.zimbra.soap.mail.type.FilterTest) Test(org.junit.Test)

Example 3 with GetDistributionListMembersResponse

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

the class TestDelegatedDL method hideInGal.

@Test
@Bug(bug = 66234)
public void hideInGal() throws Exception {
    // setup GAL sync account
    GalTestUtil.enableGalSyncAccount(prov, domain.getName());
    String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
    Multimap<String, String> attrs = ArrayListMultimap.create();
    attrs.put(Provisioning.A_zimbraHideInGal, ProvisioningConstants.TRUE);
    // create an owner account
    Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
    Group group = createGroupAndAddOwner(GROUP_NAME, attrs, ownerAcct.getName());
    // create member accounts and add it to the group
    Account memberAcct1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
    Account memberAcct2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
    Account memberAcct3 = provUtil.createAccount(genAcctNameLocalPart("member3"), domain);
    prov.addGroupMembers(group, new String[] { memberAcct3.getName(), memberAcct2.getName(), memberAcct1.getName() });
    // create a non-member account
    Account nonMemberAcct = provUtil.createAccount(genAcctNameLocalPart("non-member"), domain);
    /*
         * Owners should be able to see members even when the list is hideInGal
         */
    // auth as the owner
    SoapTransport transport = authUser(ownerAcct.getName());
    GetDistributionListMembersRequest req = new GetDistributionListMembersRequest(null, null, group.getName());
    GetDistributionListMembersResponse resp = invokeJaxb(transport, req);
    List<String> members = resp.getDlMembers();
    //make sure members are returned sorted
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
    // add another member, verify cache is updated
    Account memberAcct4 = provUtil.createAccount(genAcctNameLocalPart("member4"), domain);
    prov.addGroupMembers(group, new String[] { memberAcct4.getName() });
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName()), members);
    String errorCode = null;
    /*
         * non owner cannot see members when the list is hideInGal
         */
    transport = authUser(memberAcct1.getName());
    errorCode = null;
    try {
        invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
    /*
         * non owner cannot see members when the list is hideInGal
         */
    transport = authUser(nonMemberAcct.getName());
    errorCode = null;
    try {
        invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
    GalTestUtil.disableGalSyncAccount(prov, domain.getName());
    provUtil.deleteAccount(ownerAcct);
    provUtil.deleteAccount(memberAcct1);
    provUtil.deleteAccount(memberAcct2);
    provUtil.deleteAccount(memberAcct3);
    provUtil.deleteAccount(memberAcct4);
    provUtil.deleteAccount(nonMemberAcct);
    provUtil.deleteGroup(group);
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) GetDistributionListMembersResponse(com.zimbra.soap.account.message.GetDistributionListMembersResponse) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) GetDistributionListMembersRequest(com.zimbra.soap.account.message.GetDistributionListMembersRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 4 with GetDistributionListMembersResponse

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

the class TestDLMembership method testGetDistributionListMembers.

@Test
public void testGetDistributionListMembers() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(testUser.getName())));
        AddDistributionListMemberResponse addDLMemberResp2 = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL2.getId(), Collections.singleton(testUser2.getName())));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //Verify GetDistributionListMembersRequest returns correct members.
        SoapTransport transportAccount = TestUtil.authUser(testUser.getName(), TestUtil.DEFAULT_PASSWORD);
        GetDistributionListMembersResponse resp = SoapTest.invokeJaxb(transportAccount, new GetDistributionListMembersRequest(0, 0, testDL2.getName()));
        List<String> dlInfoList = resp.getDlMembers();
        assertFalse("Unexepcted member present", dlInfoList.contains(testUser.getName()));
        assertTrue("DL member not present", dlInfoList.contains(testUser2.getName()));
        resp = SoapTest.invokeJaxb(transportAccount, new GetDistributionListMembersRequest(0, 0, testDL.getName()));
        dlInfoList = resp.getDlMembers();
        assertFalse("Unexepcted member present", dlInfoList.contains(testUser2.getName()));
        assertTrue("DL member not present", dlInfoList.contains(testUser.getName()));
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) GetDistributionListMembersResponse(com.zimbra.soap.account.message.GetDistributionListMembersResponse) GetDistributionListMembersRequest(com.zimbra.soap.account.message.GetDistributionListMembersRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Aggregations

GetDistributionListMembersResponse (com.zimbra.soap.account.message.GetDistributionListMembersResponse)4 Test (org.junit.Test)4 SoapTransport (com.zimbra.common.soap.SoapTransport)3 GetDistributionListMembersRequest (com.zimbra.soap.account.message.GetDistributionListMembersRequest)3 ServiceException (com.zimbra.common.service.ServiceException)2 Account (com.zimbra.cs.account.Account)2 AccountServiceException (com.zimbra.cs.account.AccountServiceException)2 Group (com.zimbra.cs.account.Group)2 Bug (com.zimbra.qa.QA.Bug)2 Element (com.zimbra.common.soap.Element)1 JSONElement (com.zimbra.common.soap.Element.JSONElement)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)1 AddDistributionListMemberRequest (com.zimbra.soap.admin.message.AddDistributionListMemberRequest)1 AddDistributionListMemberResponse (com.zimbra.soap.admin.message.AddDistributionListMemberResponse)1 FilterTest (com.zimbra.soap.mail.type.FilterTest)1 XmlAnyElement (javax.xml.bind.annotation.XmlAnyElement)1 XmlElement (javax.xml.bind.annotation.XmlElement)1