Search in sources :

Example 41 with SoapTransport

use of com.zimbra.common.soap.SoapTransport 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 42 with SoapTransport

use of com.zimbra.common.soap.SoapTransport 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 43 with SoapTransport

use of com.zimbra.common.soap.SoapTransport 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 44 with SoapTransport

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

the class TestUtil method waitForSessions.

public static QueryWaitSetResponse waitForSessions(int numExpectedSessions, int numExpectedFolderInterests, int timeout_millis, String wsID, Server server) throws Exception {
    QueryWaitSetResponse resp = null;
    while (timeout_millis > 0) {
        QueryWaitSetRequest req = new QueryWaitSetRequest(wsID);
        SoapTransport transport = getAdminSoapTransport(server);
        resp = JaxbUtil.elementToJaxb(transport.invoke(JaxbUtil.jaxbToElement(req)));
        List<WaitSetInfo> wsInfoList = resp.getWaitsets();
        assertFalse("Expecting to find a waitset", wsInfoList.isEmpty());
        assertEquals("Expecting to find only one waitset", 1, wsInfoList.size());
        WaitSetInfo wsInfo = wsInfoList.get(0);
        assertEquals("Found wrong waitset", wsID, wsInfo.getWaitSetId());
        List<SessionForWaitSet> sessions = wsInfo.getSessions();
        if (sessions != null && numExpectedSessions > 0) {
            if (sessions.size() == numExpectedSessions) {
                int foundFolderInterests = 0;
                for (SessionForWaitSet s : sessions) {
                    WaitSetSessionInfo sessionInfo = s.getWaitSetSession();
                    if (sessionInfo != null) {
                        foundFolderInterests += s.getWaitSetSession().getFolderInterestsAsSet().size();
                    }
                }
                if (foundFolderInterests == numExpectedFolderInterests) {
                    return resp;
                }
            }
        } else if ((sessions == null || sessions.isEmpty()) && numExpectedSessions == 0) {
            return resp;
        }
        try {
            if (timeout_millis > 500) {
                Thread.sleep(500);
                timeout_millis = timeout_millis - 500;
            } else {
                Thread.sleep(timeout_millis);
                timeout_millis = 0;
            }
        } catch (InterruptedException e) {
            ZimbraLog.test.debug("sleep got interrupted", e);
        }
    }
    return resp;
}
Also used : WaitSetSessionInfo(com.zimbra.soap.admin.type.WaitSetSessionInfo) WaitSetInfo(com.zimbra.soap.admin.type.WaitSetInfo) QueryWaitSetResponse(com.zimbra.soap.admin.message.QueryWaitSetResponse) SessionForWaitSet(com.zimbra.soap.admin.type.SessionForWaitSet) QueryWaitSetRequest(com.zimbra.soap.admin.message.QueryWaitSetRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) ZMountpoint(com.zimbra.client.ZMountpoint)

Example 45 with SoapTransport

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

the class TestAccess method DeleteDataSource.

@Test
public void DeleteDataSource() throws Exception {
    String dateSourceName = genDataSourceName(seq);
    // create a data cource
    SoapTransport transport = authUser(ACCT_NAME);
    CreateDataSourceRequest createReq = buildCeateDataSourceRequest(dateSourceName);
    CreateDataSourceResponse createResp = invokeJaxb(transport, createReq);
    assertNotNull("CreateDataSourceResponse", createResp);
    Pop3DataSourceNameOrId name = new Pop3DataSourceNameOrId();
    name.setName(dateSourceName);
    DeleteDataSourceRequest req = new DeleteDataSourceRequest();
    req.addDataSource(name);
    /*
        DataSource ds = mProvAdmin.setup_createDataSource(this, role, perm, ACCT_1_EMAIL, dateSourceName);

        XMLElement req = new XMLElement(MailConstants.DELETE_DATA_SOURCE_REQUEST);
        Element dataSource = req.addElement(MailConstants.E_DS_POP3);
        dataSource.addAttribute(MailConstants.A_ID, ds.getId());
        */
    accessTest(Perm.PERM_SELF_ONLY, req);
}
Also used : DeleteDataSourceRequest(com.zimbra.soap.mail.message.DeleteDataSourceRequest) CreateDataSourceResponse(com.zimbra.soap.mail.message.CreateDataSourceResponse) Pop3DataSourceNameOrId(com.zimbra.soap.mail.type.Pop3DataSourceNameOrId) SoapTransport(com.zimbra.common.soap.SoapTransport) CreateDataSourceRequest(com.zimbra.soap.mail.message.CreateDataSourceRequest) 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