Search in sources :

Example 1 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testAddMemberByName.

@Test
public void testAddMemberByName() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add a member by account name
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(testUser.getName())));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) ArrayList(java.util.ArrayList) DLInfo(com.zimbra.soap.admin.type.DLInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 2 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testRemoveMemberByAlias.

@Test
public void testRemoveMemberByAlias() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add an alias to the account
        AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
        assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
        Account acct = Provisioning.getInstance().getAccount(testUser.getId());
        assertNotNull(acct);
        assertNotNull("account's aliases are null", acct.getAliases());
        assertEquals("account has no aliases", acct.getAliases().length, 1);
        //add account to DL by alias
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
        //remove the account's alias from the DL
        RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), Arrays.asList(new String[] { TestUtil.getAddress(TEST_ALIAS) })));
        assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
        //verify that account is NOT a member of the DL anymore
        result = new ArrayList<DistributionList>();
        resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        dlInfoList = resp.getDlList();
        assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : Account(com.zimbra.cs.account.Account) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) ArrayList(java.util.ArrayList) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 3 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDLMembership method testRemoveMemberByName.

@Test
public void testRemoveMemberByName() {
    SoapTransport transport;
    try {
        transport = TestUtil.getAdminSoapTransport();
        //add an alias to the account
        AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
        assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
        Account acct = Provisioning.getInstance().getAccount(testUser.getId());
        assertNotNull(acct);
        assertNotNull("account's aliases are null", acct.getAliases());
        assertEquals("account has no aliases", acct.getAliases().length, 1);
        //add account to DL by alias
        AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
        assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
        //verify that account is a member of the DL
        ArrayList<DistributionList> result = new ArrayList<DistributionList>();
        GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        List<DLInfo> dlInfoList = resp.getDlList();
        assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
        assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
        //remove the account's alias from the DL
        RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), null, Arrays.asList(new String[] { TestUtil.getAddress(TEST_USER) })));
        assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
        //verify that account is NOT a member of the DL anymore
        result = new ArrayList<DistributionList>();
        resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
        assertNotNull("GetAccountMembershipRequest cannot be null", resp);
        dlInfoList = resp.getDlList();
        assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : Account(com.zimbra.cs.account.Account) GetAccountMembershipResponse(com.zimbra.soap.admin.message.GetAccountMembershipResponse) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) ArrayList(java.util.ArrayList) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) DLInfo(com.zimbra.soap.admin.type.DLInfo) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) GetAccountMembershipRequest(com.zimbra.soap.admin.message.GetAccountMembershipRequest) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionList(com.zimbra.cs.account.DistributionList) Test(org.junit.Test) SoapTest(com.zimbra.qa.unittest.prov.soap.SoapTest)

Example 4 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testViaGroupDelegatedAdminAssignSendToDistList.

/**
     * Test that delegated admin with adminConsoleDLACLTabRights can grant sendToDistList right
     * @throws Exception
     */
@Test
public void testViaGroupDelegatedAdminAssignSendToDistList() throws Exception {
    String domAdminGroupId = createAdminConsoleStyleDomainAdminGroup(DOMADMINGROUP);
    CreateAccountResponse caResp;
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE"));
    CreateAccountRequest caReq = new CreateAccountRequest(DOMADMIN, TestUtil.DEFAULT_PASSWORD, attrs);
    caResp = adminSoapProv.invokeJaxb(caReq);
    assertNotNull("CreateAccountResponse for " + DOMADMIN + " Admin", caResp);
    AddDistributionListMemberResponse adlmResp;
    adlmResp = adminSoapProv.invokeJaxb(new AddDistributionListMemberRequest(domAdminGroupId, Lists.newArrayList(DOMADMIN)));
    assertNotNull("AddDistributionListMemberResponse for " + DOMADMIN + " Admin", adlmResp);
    adminSoapProv.createAccount(TARGET_ACCT, TestUtil.DEFAULT_PASSWORD, null);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    CreateDistributionListResponse cdlResp;
    cdlResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL));
    assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", cdlResp);
    cdlResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL));
    assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", cdlResp);
    failToGrantRight(domAdminSoapProv, TargetType.dl, TARGET_DL, TARGET_ACCT, RightConsts.RT_sendToDistList, "permission denied: insufficient right to grant 'sendToDistList' right");
    grantRight(adminSoapProv, TargetType.domain, ADMINISTERED_DOMAIN, GranteeType.grp, DOMADMINGROUP, RightConsts.RT_adminConsoleDLACLTabRights);
    grantRight(domAdminSoapProv, TargetType.dl, TARGET_DL, TARGET_ACCT, RightConsts.RT_sendToDistList);
    /* Check that doesn't allow it for a dl in a different domain */
    failToGrantRight(domAdminSoapProv, TargetType.dl, DIFF_DL, TARGET_ACCT, RightConsts.RT_sendToDistList, "permission denied: insufficient right to grant 'sendToDistList' right");
}
Also used : CreateAccountResponse(com.zimbra.soap.admin.message.CreateAccountResponse) CreateAccountRequest(com.zimbra.soap.admin.message.CreateAccountRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) Attr(com.zimbra.soap.admin.type.Attr) Test(org.junit.Test)

Example 5 with AddDistributionListMemberResponse

use of com.zimbra.soap.admin.message.AddDistributionListMemberResponse in project zm-mailbox by Zimbra.

the class TestDelegatedDL method noHomeServerZimbraAdmin.

/*
     * Verify groups without a home server will get executed for zimbraAdmin
     * SOAP calls.
     */
@Test
@Bug(bug = 66412)
public void noHomeServerZimbraAdmin() throws Exception {
    String groupName = TestUtil.getAddress(genGroupNameLocalPart(), DOMAIN_NAME);
    Group group = provUtil.createGroup(groupName, DYNAMIC);
    String groupId = group.getId();
    // remove zimbraMailHost
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraMailHost, null);
    prov.modifyAttrs(group, attrs);
    SoapTransport transport = authAdmin(ADMIN);
    Object req;
    com.zimbra.soap.admin.type.DistributionListInfo dlInfo;
    /*
         * GetDistributionList
         */
    req = new com.zimbra.soap.admin.message.GetDistributionListRequest(com.zimbra.soap.admin.type.DistributionListSelector.fromName(groupName));
    com.zimbra.soap.admin.message.GetDistributionListResponse getDLResp = invokeJaxb(transport, req);
    dlInfo = getDLResp.getDl();
    assertEquals(groupId, dlInfo.getId());
    /*
         * ModifyDistributionList
         */
    req = new ModifyDistributionListRequest(groupId);
    ModifyDistributionListResponse modifyDLResp = invokeJaxb(transport, req);
    dlInfo = modifyDLResp.getDl();
    assertEquals(groupId, dlInfo.getId());
    /*
         * AddDistributionAlias
         */
    req = new AddDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
    AddDistributionListAliasResponse addDLAliasResp = invokeJaxb(transport, req);
    /*
         * RemoveDistributionAlias
         */
    req = new RemoveDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
    RemoveDistributionListAliasResponse removeDLAliasResp = invokeJaxb(transport, req);
    /*
         * AddDistributionListMember
         */
    req = new AddDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
    AddDistributionListMemberResponse addDLMemberResp = invokeJaxb(transport, req);
    /*
         * RemoveDistributionListMember
         */
    req = new RemoveDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
    RemoveDistributionListMemberResponse removeDLMemberResp = invokeJaxb(transport, req);
    /*
         * DeleteDistributionList
         */
    req = new DeleteDistributionListRequest(groupId);
    DeleteDistributionListResponse deleteDLResp = invokeJaxb(transport, req);
}
Also used : Group(com.zimbra.cs.account.Group) RemoveDistributionListAliasRequest(com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) AddDistributionListAliasRequest(com.zimbra.soap.admin.message.AddDistributionListAliasRequest) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) RemoveDistributionListAliasResponse(com.zimbra.soap.admin.message.RemoveDistributionListAliasResponse) RemoveDistributionListMemberRequest(com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) ModifyDistributionListRequest(com.zimbra.soap.admin.message.ModifyDistributionListRequest) DeleteDistributionListRequest(com.zimbra.soap.admin.message.DeleteDistributionListRequest) DeleteDistributionListResponse(com.zimbra.soap.admin.message.DeleteDistributionListResponse) AddDistributionListAliasResponse(com.zimbra.soap.admin.message.AddDistributionListAliasResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) ModifyDistributionListResponse(com.zimbra.soap.admin.message.ModifyDistributionListResponse) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Aggregations

AddDistributionListMemberResponse (com.zimbra.soap.admin.message.AddDistributionListMemberResponse)8 AddDistributionListMemberRequest (com.zimbra.soap.admin.message.AddDistributionListMemberRequest)7 Test (org.junit.Test)7 SoapTransport (com.zimbra.common.soap.SoapTransport)6 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)5 GetAccountMembershipRequest (com.zimbra.soap.admin.message.GetAccountMembershipRequest)4 GetAccountMembershipResponse (com.zimbra.soap.admin.message.GetAccountMembershipResponse)4 DLInfo (com.zimbra.soap.admin.type.DLInfo)4 Account (com.zimbra.cs.account.Account)3 DistributionList (com.zimbra.cs.account.DistributionList)3 AddAccountAliasRequest (com.zimbra.soap.admin.message.AddAccountAliasRequest)3 AddAccountAliasResponse (com.zimbra.soap.admin.message.AddAccountAliasResponse)3 RemoveDistributionListMemberRequest (com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest)3 RemoveDistributionListMemberResponse (com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse)3 ArrayList (java.util.ArrayList)3 Group (com.zimbra.cs.account.Group)2 Provisioning (com.zimbra.cs.account.Provisioning)1 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)1 OperationContext (com.zimbra.cs.mailbox.OperationContext)1 Bug (com.zimbra.qa.QA.Bug)1