Search in sources :

Example 1 with GetDistributionListMembersRequest

use of com.zimbra.soap.account.message.GetDistributionListMembersRequest 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 GetDistributionListMembersRequest

use of com.zimbra.soap.account.message.GetDistributionListMembersRequest 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 3 with GetDistributionListMembersRequest

use of com.zimbra.soap.account.message.GetDistributionListMembersRequest 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

SoapTransport (com.zimbra.common.soap.SoapTransport)3 GetDistributionListMembersRequest (com.zimbra.soap.account.message.GetDistributionListMembersRequest)3 GetDistributionListMembersResponse (com.zimbra.soap.account.message.GetDistributionListMembersResponse)3 Test (org.junit.Test)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 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