use of com.zimbra.common.soap.SoapHttpTransport in project zm-mailbox by Zimbra.
the class TestSoap method testAccountGetInfoRequest.
/**
* Tests the AccountService version of GetInfoRequest (see bug 30010).
*/
@Test
public void testAccountGetInfoRequest() throws Exception {
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getSoapUrl());
Element request = Element.create(transport.getRequestProtocol(), AccountConstants.GET_VERSION_INFO_REQUEST);
// Test with version exposed
TestUtil.setServerAttr(Provisioning.A_zimbraSoapExposeVersion, LdapConstants.LDAP_TRUE);
Element response = transport.invoke(request);
validateSoapVersionResponse(response);
// Test with version not exposed
TestUtil.setServerAttr(Provisioning.A_zimbraSoapExposeVersion, LdapConstants.LDAP_FALSE);
request = Element.create(transport.getRequestProtocol(), AccountConstants.GET_VERSION_INFO_REQUEST);
try {
response = transport.invoke(request);
Assert.fail("GetInfoRequest should have failed");
} catch (SoapFaultException e) {
Assert.assertEquals(ServiceException.PERM_DENIED, e.getCode());
}
}
use of com.zimbra.common.soap.SoapHttpTransport in project zm-mailbox by Zimbra.
the class TestSendAndReceive method testSendNoDraft.
@Test
public void testSendNoDraft() throws Exception {
TestUtil.createAccount(USER_NAME);
TestUtil.createAccount(REMOTE_USER_NAME);
MailSender.registerPreSendMailListener(listener);
//register second time to test that it will be triggered once
MailSender.registerPreSendMailListener(listener);
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
String subj = "Dwalin";
String body = "To dungeons deep, and caverns old";
String customHeaderValue = "http://zss.server/file1";
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getSoapUrl());
transport.setAuthToken(zmbox.getAuthToken());
//create a draft with a custom mime header
Element request = new Element.JSONElement(MailConstants.SEND_MSG_REQUEST);
Element el = request.addUniqueElement(MailConstants.E_MSG);
el.addAttribute(MailConstants.E_SUBJECT, subj);
el.addUniqueElement(MailConstants.E_MIMEPART).addAttribute(MailConstants.A_CONTENT_TYPE, "text/plain").addAttribute(MailConstants.E_CONTENT, body);
el.addNonUniqueElement(MailConstants.E_EMAIL).addAttribute(MailConstants.A_ADDRESS_TYPE, EmailType.TO.toString()).addAttribute(MailConstants.A_ADDRESS, TestUtil.addDomainIfNecessary(REMOTE_USER_NAME));
el.addNonUniqueElement(MailConstants.E_HEADER).addAttribute(MailConstants.A_NAME, MailSender.PRE_SEND_HEADER).setText("custom");
el.addNonUniqueElement(MailConstants.E_HEADER).addAttribute(MailConstants.A_NAME, PUBLIC_LIST_HEADER).setText(customHeaderValue);
transport.invoke(request);
Assert.assertTrue("Listener was not triggered", listener.isTriggered());
Assert.assertEquals("listener should ahve been triggered only once", 1, listener.getTriggerCounter());
String[] listenersData = listener.getData();
Assert.assertNotNull("Listener did not get data from custom headers", listenersData);
Assert.assertTrue("wrong number of elements in custom header data", listenersData.length == 1);
Assert.assertTrue("wrong value in custom header", customHeaderValue.equalsIgnoreCase(listenersData[0].replace("\"", "")));
}
use of com.zimbra.common.soap.SoapHttpTransport in project zm-mailbox by Zimbra.
the class TestSendAndReceive method testMultipleHeaders.
@Test
public void testMultipleHeaders() throws Exception {
TestUtil.createAccount(USER_NAME);
TestUtil.createAccount(REMOTE_USER_NAME);
MailSender.registerPreSendMailListener(listener);
//register second time to test that it will be triggered once
MailSender.registerPreSendMailListener(listener);
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
String subj = "Dwalin";
String body = "To dungeons deep, and caverns old";
String customHeaderValue1 = "http://zss.server/file1";
String customHeaderValue2 = "http://zss.server/file2";
String customHeaderValue3 = "http://zss.server/file3";
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getSoapUrl());
transport.setAuthToken(zmbox.getAuthToken());
//create a draft with a custom mime header
Element request = new Element.JSONElement(MailConstants.SEND_MSG_REQUEST);
Element el = request.addUniqueElement(MailConstants.E_MSG);
el.addAttribute(MailConstants.E_SUBJECT, subj);
el.addUniqueElement(MailConstants.E_MIMEPART).addAttribute(MailConstants.A_CONTENT_TYPE, "text/plain").addAttribute(MailConstants.E_CONTENT, body);
el.addNonUniqueElement(MailConstants.E_EMAIL).addAttribute(MailConstants.A_ADDRESS_TYPE, EmailType.TO.toString()).addAttribute(MailConstants.A_ADDRESS, TestUtil.addDomainIfNecessary(REMOTE_USER_NAME));
el.addNonUniqueElement(MailConstants.E_HEADER).addAttribute(MailConstants.A_NAME, MailSender.PRE_SEND_HEADER).setText("custom");
el.addNonUniqueElement(MailConstants.E_HEADER).addAttribute(MailConstants.A_NAME, PUBLIC_LIST_HEADER).setText(customHeaderValue1);
el.addNonUniqueElement(MailConstants.E_HEADER).addAttribute(MailConstants.A_NAME, PUBLIC_LIST_HEADER).setText(customHeaderValue2);
el.addNonUniqueElement(MailConstants.E_HEADER).addAttribute(MailConstants.A_NAME, PUBLIC_LIST_HEADER).setText(customHeaderValue3);
transport.invoke(request);
Assert.assertTrue("Listener was not triggered", listener.isTriggered());
Assert.assertEquals("listener should ahve been triggered only once", 1, listener.getTriggerCounter());
String[] listenersData = listener.getData();
Assert.assertNotNull("Listener did not get data from custom headers", listenersData);
Assert.assertEquals("wrong number of elements in custom header data", 3, listenersData.length);
List<String> valueList = Arrays.asList(listenersData);
Assert.assertTrue(customHeaderValue1 + " is missing", valueList.contains(String.format("\"%s\"", customHeaderValue1)));
Assert.assertTrue(customHeaderValue2 + " is missing", valueList.contains(String.format("\"%s\"", customHeaderValue2)));
Assert.assertTrue(customHeaderValue3 + " is missing", valueList.contains(String.format("\"%s\"", customHeaderValue3)));
}
use of com.zimbra.common.soap.SoapHttpTransport in project zm-mailbox by Zimbra.
the class SoapTest method authUser.
static SoapTransport authUser(String acctName, String password) throws Exception {
com.zimbra.soap.type.AccountSelector acct = new com.zimbra.soap.type.AccountSelector(com.zimbra.soap.type.AccountBy.name, acctName);
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getSoapUrl());
transport.setHttpDebugListener(soapDebugListener);
AuthRequest req = new AuthRequest(acct, password);
AuthResponse resp = invokeJaxb(transport, req);
transport.setAuthToken(resp.getAuthToken());
return transport;
}
use of com.zimbra.common.soap.SoapHttpTransport in project zm-mailbox by Zimbra.
the class FbCli method setServer.
public void setServer(String server) {
String adminUrl = URLUtil.getAdminURL(server);
mTransport = new SoapHttpTransport(adminUrl);
}
Aggregations