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);
}
}
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());
}
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());
}
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));
}
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);
}
Aggregations