use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDeployZimlet method testBadZimletName.
@Test
public void testBadZimletName() throws Exception {
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
authReq.setCsrfSupported(false);
Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
String authToken = authResp.getAuthToken();
String aid = adminUpload(authToken, "attack.zip", "/opt/zimbra/unittest/zimlets/attack.zip");
assertNotNull("Attachment ID should not be null", aid);
AttachmentIdAttrib att = new AttachmentIdAttrib(aid);
transport.setAdmin(true);
transport.setAuthToken(authToken);
DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
Element req = JaxbUtil.jaxbToElement(deployReq);
try {
Element res = transport.invoke(req);
JaxbUtil.elementToJaxb(res);
fail("Should throw SoapFaultException");
} catch (SoapFaultException e) {
// expected
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDeployZimlet method testZipWithAbsolutePath.
@Test
public void testZipWithAbsolutePath() throws Exception {
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
authReq.setCsrfSupported(false);
Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
String authToken = authResp.getAuthToken();
String aid = adminUpload(authToken, "absolute.zip", "/opt/zimbra/unittest/zimlets/absolute.zip");
assertNotNull("Attachment ID should not be null", aid);
AttachmentIdAttrib att = new AttachmentIdAttrib(aid);
transport.setAdmin(true);
transport.setAuthToken(authToken);
DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
Element req = JaxbUtil.jaxbToElement(deployReq);
try {
Element res = transport.invoke(req);
JaxbUtil.elementToJaxb(res);
fail("Should throw SoapFaultException");
} catch (SoapFaultException e) {
// expected
}
// check that file did not get extracted to absolute path
File rogueFile = new File("/opt/zimbra/conf/rogue.file");
assertFalse("/opt/zimbra/conf/rogue.file should not have been created", rogueFile.exists());
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDeployZimlet method testNoAid.
@Test
public void testNoAid() throws Exception {
SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
authReq.setCsrfSupported(false);
Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
String authToken = authResp.getAuthToken();
transport.setAdmin(true);
transport.setAuthToken(authToken);
DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, null);
Element req = JaxbUtil.jaxbToElement(deployReq);
try {
Element res = transport.invoke(req);
JaxbUtil.elementToJaxb(res);
fail("Should throw SoapFaultException");
} catch (SoapFaultException e) {
// expected
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestCookieReuse method testInvalidSearchRequest.
/**
* Verify that we canNOT RE-use the cookie taken from a legitimate HTTP session for a SOAP request after
* ending the original session
*/
@Test
public void testInvalidSearchRequest() throws ServiceException, IOException, HttpException {
// establish legitimate connection
TestUtil.setAccountAttr(USER_NAME, Provisioning.A_zimbraForceClearCookies, "FALSE");
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
URI uri = mbox.getRestURI("Inbox?fmt=rss");
mbox.getHttpClient(uri);
ZAuthToken authT = mbox.getAuthToken();
// create evesdropper's SOAP client
SoapHttpTransport transport = new HttpCookieSoapTransport(TestUtil.getSoapUrl());
transport.setAuthToken(authT);
// check that search returns something
SearchRequest searchReq = new SearchRequest();
searchReq.setSearchTypes(MailItem.Type.MESSAGE.toString());
searchReq.setQuery("in:inbox");
Element req = JaxbUtil.jaxbToElement(searchReq, SoapProtocol.SoapJS.getFactory());
Element res = transport.invoke(req);
SearchResponse searchResp = JaxbUtil.elementToJaxb(res);
List<SearchHit> searchHits = searchResp.getSearchHits();
Assert.assertFalse("this search request should return some conversations", searchHits.isEmpty());
// explicitely end cookie session
Account a = TestUtil.getAccount(USER_NAME);
a.setForceClearCookies(false);
EndSessionRequest esr = new EndSessionRequest();
esr.setLogOff(true);
mbox.invokeJaxb(esr);
// check that search returns nothing
transport = new HttpCookieSoapTransport(TestUtil.getSoapUrl());
transport.setAuthToken(authT);
searchReq = new SearchRequest();
searchReq.setSearchTypes(MailItem.Type.MESSAGE.toString());
searchReq.setQuery("in:inbox");
try {
req = JaxbUtil.jaxbToElement(searchReq, SoapProtocol.SoapJS.getFactory());
res = transport.invoke(req);
searchResp = JaxbUtil.elementToJaxb(res);
searchHits = searchResp.getSearchHits();
Assert.assertTrue("this search request should fail", searchHits.isEmpty());
} catch (SoapFaultException ex) {
Assert.assertEquals("Should be getting 'auth required' exception", ServiceException.AUTH_EXPIRED, ex.getCode());
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestLockoutMailbox method testLockoutSufficientPermissions.
@Test
public void testLockoutSufficientPermissions() throws Exception {
Mailbox mbox = TestUtil.getMailbox(MY_USER);
TestUtil.addMessage(mbox, "test");
TestUtil.waitForMessage(TestUtil.getZMailbox(MY_USER), "test");
List<AdminRight> relatedRights = new ArrayList<AdminRight>();
List<String> notes = new ArrayList<String>();
AdminDocumentHandler handler = new LockoutMailbox();
handler.docRights(relatedRights, notes);
createDelegatedAdmin(relatedRights);
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_USER));
req.setOperation(AdminConstants.A_START);
try {
LockoutMailboxResponse resp = delegatedSoapProv.invokeJaxb(req);
assertNotNull("LockoutMailboxResponse should not be null", resp);
} catch (SoapFaultException e) {
fail("should not be getting an exception");
}
req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_NON_EXISTING_USER));
req.setOperation(AdminConstants.A_START);
try {
delegatedSoapProv.invokeJaxb(req);
fail("should have caught an exception");
} catch (SoapFaultException e) {
assertEquals("should be getting 'no such account' response", AccountServiceException.NO_SUCH_ACCOUNT, e.getCode());
}
}
Aggregations