Search in sources :

Example 76 with SoapTransport

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

the class TestSearchCalendarResources method searchByName.

private void searchByName(boolean ldap, String domainName) throws Exception {
    SoapTransport transport = authUser(TestUtil.getAddress(AUTHED_USER, domainName));
    Element request = Element.create(transport.getRequestProtocol(), AccountConstants.SEARCH_CALENDAR_RESOURCES_REQUEST);
    request.addAttribute(MailConstants.A_QUERY_OFFSET, 1);
    request.addAttribute(MailConstants.A_QUERY_LIMIT, 2);
    request.addElement(AccountConstants.E_NAME).setText(KEY_FOR_SEARCH_BY_NAME);
    Element response = transport.invoke(request);
    boolean paginationSupported = response.getAttributeBool(AccountConstants.A_PAGINATION_SUPPORTED);
    boolean found1 = false;
    boolean found2 = false;
    boolean found3 = false;
    List<CalendarResource> resources = new ArrayList<CalendarResource>();
    for (Element eResource : response.listElements(AccountConstants.E_CALENDAR_RESOURCE)) {
        CalendarResource resource = new MockCalendarResource(eResource);
        resources.add(resource);
        if (resource.getName().equals(TestUtil.getAddress(ROOM_1, domainName))) {
            found1 = true;
        }
        if (resource.getName().equals(TestUtil.getAddress(ROOM_2, domainName))) {
            found2 = true;
        }
        if (resource.getName().equals(TestUtil.getAddress(ROOM_3, domainName))) {
            found3 = true;
        }
    }
    if (ldap) {
        // pagination is not supported
        Assert.assertFalse(paginationSupported);
        // offset and limit are not honored
        Assert.assertEquals(3, resources.size());
        Assert.assertTrue(found1);
        Assert.assertTrue(found2);
        Assert.assertTrue(found3);
    } else {
        // pagination is supported
        Assert.assertTrue(paginationSupported);
        // offset and limit are honored
        Assert.assertEquals(2, resources.size());
        // not within specified offset, at offset 0 
        Assert.assertTrue(!found1);
        // (gal sync acount mailbox search is by nameAcs order) 
        Assert.assertTrue(found2);
        Assert.assertTrue(found3);
    }
}
Also used : Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) CalendarResource(com.zimbra.cs.account.CalendarResource) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 77 with SoapTransport

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

the class TestSearchGal method searchWithDot.

/*
    static void authAdmin(SoapTransport transport, String acctName) throws Exception {
        
        Element request = Element.create(transport.getRequestProtocol(), AdminConstants.AUTH_REQUEST);
        request.addElement(AccountConstants.E_ACCOUNT).addAttribute(AccountConstants.A_BY, AccountBy.name.name()).setText(acctName);
        request.addElement(AccountConstants.E_PASSWORD).setText("test123");
        
        Element response = transport.invoke(request);
        String authToken = response.getElement(AccountConstants.E_AUTH_TOKEN).getText();
        transport.setAuthToken(authToken);
    }
    */
private void searchWithDot(boolean ldap, String domainName, int expectedNumEntries) throws Exception {
    SoapTransport transport = authUser(TestUtil.getAddress(AUTHED_USER, domainName));
    Element request = Element.create(transport.getRequestProtocol(), AccountConstants.SEARCH_GAL_REQUEST);
    request.addElement(AccountConstants.E_NAME).setText(".");
    Element response = transport.invoke(request);
    boolean paginationSupported = response.getAttributeBool(AccountConstants.A_PAGINATION_SUPPORTED);
    List<GalContact> result = new ArrayList<GalContact>();
    for (Element e : response.listElements(AdminConstants.E_CN)) {
        result.add(new GalContact(AdminConstants.A_ID, SoapProvisioning.getAttrs(e)));
    }
    if (ldap) {
        // pagination is not supported
        assertFalse(paginationSupported);
    } else {
        // pagination is supported
        assertTrue(paginationSupported);
    }
    // should find all objects, plus the authed user
    assertEquals(expectedNumEntries, result.size());
}
Also used : GalContact(com.zimbra.cs.account.GalContact) Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 78 with SoapTransport

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

the class TestSearchGal method searchByName.

private void searchByName(boolean ldap, String domainName) throws Exception {
    SoapTransport transport = authUser(TestUtil.getAddress(AUTHED_USER, domainName));
    Element request = Element.create(transport.getRequestProtocol(), AccountConstants.SEARCH_GAL_REQUEST);
    request.addElement(AccountConstants.E_NAME).setText(KEY_FOR_SEARCH_BY_NAME);
    Element response = transport.invoke(request);
    List<GalContact> result = new ArrayList<GalContact>();
    for (Element e : response.listElements(AdminConstants.E_CN)) {
        result.add(new GalContact(AdminConstants.A_ID, SoapProvisioning.getAttrs(e)));
    }
    assertEquals(NUM_ACCOUNTS, result.size());
}
Also used : GalContact(com.zimbra.cs.account.GalContact) Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 79 with SoapTransport

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

the class TestSearchGal method searchByFilter.

private void searchByFilter(boolean ldap, String domainName) throws Exception {
    SoapTransport transport = authUser(TestUtil.getAddress(AUTHED_USER, domainName));
    Element request = Element.create(transport.getRequestProtocol(), AccountConstants.SEARCH_GAL_REQUEST);
    request.addElement(AccountConstants.E_NAME).setText(".");
    Element eSearchFilter = request.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER);
    Element eConds = eSearchFilter.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_MULTICOND);
    int acctToMatch = 8;
    Element eCondResType = eConds.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_SINGLECOND);
    eCondResType.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_ATTR, ContactConstants.A_email);
    eCondResType.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_OP, Operator.has.name());
    eCondResType.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_VALUE, acctToMatch);
    String matchDepartment = getDepartment(acctToMatch, domainName);
    Element eCondResSite = eConds.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_SINGLECOND);
    eCondResSite.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_ATTR, ContactConstants.A_department);
    eCondResSite.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_OP, Operator.has.name());
    eCondResSite.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_VALUE, matchDepartment);
    Element response = transport.invoke(request);
    List<GalContact> result = new ArrayList<GalContact>();
    for (Element e : response.listElements(AdminConstants.E_CN)) {
        result.add(new GalContact(AdminConstants.A_ID, SoapProvisioning.getAttrs(e)));
    }
    assertEquals(1, result.size());
    assertEquals(getAcctEmail(acctToMatch, domainName), result.get(0).getSingleAttr(ContactConstants.A_email));
}
Also used : GalContact(com.zimbra.cs.account.GalContact) Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 80 with SoapTransport

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

the class TestExpandGroupInfo method sendMsg.

private void sendMsg(Account authAcct, String toAddress, String subject, String content) throws Exception {
    SoapTransport transport = authUser(authAcct.getName());
    MsgToSend msg = new MsgToSend();
    EmailAddrInfo toAddr = new EmailAddrInfo(toAddress);
    toAddr.setAddressType(EmailType.TO.toString());
    msg.addEmailAddress(toAddr);
    msg.setSubject(subject);
    MimePartInfo mp = new MimePartInfo();
    mp.setContentType("text/plain");
    mp.setContent(content);
    msg.setMimePart(mp);
    SendMsgRequest req = new SendMsgRequest();
    req.setMsg(msg);
    SendMsgResponse resp = invokeJaxb(transport, req);
}
Also used : EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) MsgToSend(com.zimbra.soap.mail.type.MsgToSend) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) SendMsgRequest(com.zimbra.soap.mail.message.SendMsgRequest) SendMsgResponse(com.zimbra.soap.mail.message.SendMsgResponse) SoapTransport(com.zimbra.common.soap.SoapTransport)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)85 Test (org.junit.Test)66 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)16 SoapFaultException (com.zimbra.common.soap.SoapFaultException)15 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 ArrayList (java.util.ArrayList)10 SoapProtocol (com.zimbra.common.soap.SoapProtocol)9 Bug (com.zimbra.qa.QA.Bug)9 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)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