use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestMaxMessageSize method testLimitByFileUploadMaxSize.
@Test
public void testLimitByFileUploadMaxSize() throws Exception {
setMaxMessageSize(TEST_MAX_MESSAGE_SIZE);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
try {
InputStream in = new ByteArrayInputStream(new byte[3000]);
mbox.uploadContentAsStream("testLimitByFileUploadMaxSize1", in, "application/octet-stream", 3000, 5000);
Assert.fail("upload should not have succeeded");
} catch (ServiceException e) {
;
}
try {
InputStream in = new ByteArrayInputStream(new byte[3000]);
mbox.uploadContentAsStream("testLimitByFileUploadMaxSize2", in, "application/octet-stream", 3000, 5000, true);
} catch (SoapFaultException e) {
Assert.fail("upload should not have failed");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetAccountInDomAdminDomain.
@Test
public void testGetAccountInDomAdminDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
CreateAccountResponse caResp;
caResp = domAdminSoapProv.invokeJaxb(new CreateAccountRequest(TARGET_ACCT, TestUtil.DEFAULT_PASSWORD));
assertNotNull("CreateAccountResponse for " + TARGET_ACCT + " simple as domAdmin", caResp);
String acctId = caResp.getAccount().getId();
GetAccountRequest getAcctReq = new GetAccountRequest(AccountSelector.fromName(TARGET_ACCT), true);
GetAccountResponse getAcctResp = domAdminSoapProv.invokeJaxb(getAcctReq);
assertNotNull("GetAccountResponse for " + TARGET_ACCT + " simple as domAdmin", getAcctResp);
getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
assertNotNull("GetAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", getAcctResp);
GetMailboxRequest gmReq = new GetMailboxRequest(new MailboxByAccountIdSelector(acctId));
GetMailboxResponse gmResp = domAdminSoapProv.invokeJaxb(gmReq);
assertNotNull("GetMailboxResponse for " + TARGET_ACCT + " simple as domAdmin", gmResp);
gmResp = domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
assertNotNull("GetMailboxResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", gmResp);
AddAccountAliasResponse aaaResp;
aaaResp = domAdminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
assertNotNull("AddAccountAliasResponse for " + TARGET_ACCT + " simple as domAdmin", aaaResp);
aaaResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT2), acctId);
assertNotNull("AddAccountAliasResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", aaaResp);
RemoveAccountAliasResponse daaResp;
daaResp = domAdminSoapProv.invokeJaxb(new RemoveAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
assertNotNull("RemoveAccountAliasResponse for " + TARGET_ACCT + " simple as domAdmin", daaResp);
daaResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new RemoveAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT2), acctId);
assertNotNull("RemoveAccountAliasResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", daaResp);
RenameAccountResponse renAResp;
renAResp = domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, TARGET_ACCT_RENAMED));
assertNotNull("RenameAccountResponse for " + TARGET_ACCT + " simple as domAdmin", renAResp);
renAResp = domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, TARGET_ACCT));
assertNotNull("RenameAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", renAResp);
DeleteAccountRequest delAcctReq;
DeleteAccountResponse delAcctResp;
delAcctReq = new DeleteAccountRequest(null);
try {
delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
fail("DeleteAccountRequest succeeded in spite of having no 'id' specified!!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
delAcctReq = new DeleteAccountRequest(acctId);
delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
assertNotNull("DeleteAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", delAcctResp);
try {
getAcctResp = domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "no such account: ");
}
try {
getAcctResp = domAdminSoapProv.invokeJaxb(new GetAccountRequest(AccountSelector.fromId(acctId), true));
fail("GetAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// because by id not name
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
fail("GetAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
gmResp = domAdminSoapProv.invokeJaxb(gmReq);
fail("GetMailboxRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// because by id
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
gmResp = domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
fail("GetMailboxRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetCalendarResourceInDiffDomain.
@Test
public void testGetCalendarResourceInDiffDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr(Provisioning.A_displayName, "testGetCalendarResourceInDiffDomain Room 101"));
attrs.add(new Attr(Provisioning.A_description, "Room 101 for 50 seats"));
attrs.add(new Attr(Provisioning.A_zimbraCalResType, "Location"));
attrs.add(new Attr(Provisioning.A_zimbraCalResAutoAcceptDecline, "TRUE"));
attrs.add(new Attr(Provisioning.A_zimbraCalResAutoDeclineIfBusy, "TRUE"));
CreateCalendarResourceResponse caResp;
try {
caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
fail("CreateCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: need right: createCalendarResource for domain");
}
caResp = adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
assertNotNull("CreateCalendarResourceResponse for " + DIFF_CALRES + " simple as domAdmin", caResp);
String acctId = caResp.getCalResource().getId();
GetCalendarResourceRequest getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES), true);
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
fail("GetCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
// try non-existent
getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES2), true);
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetCalendarResourceRequest succeeded for non-existent account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
fail("RenameCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
domAdminSoapProv.invokeJaxb(new DeleteCalendarResourceRequest(acctId));
fail("DeleteCalendarResourceRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testModifyDistributionListInDiffDomain.
@Test
public void testModifyDistributionListInDiffDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr(Provisioning.A_displayName, "testGetDistributionListInDiffDomain Room 101"));
CreateDistributionListResponse caResp;
caResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL, attrs, false));
assertNotNull("CreateDistributionListResponse for " + DIFF_DL + " as FULL ADMIN", caResp);
String dlId = caResp.getDl().getId();
ModifyDistributionListRequest modAcctReq = new ModifyDistributionListRequest(dlId);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
try {
domAdminSoapProv.invokeJaxb(modAcctReq);
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access distribution list ");
}
DeleteDistributionListRequest delAcctReq = new DeleteDistributionListRequest(dlId);
DeleteDistributionListResponse delAcctResp = adminSoapProv.invokeJaxb(delAcctReq);
assertNotNull("DeleteDistributionListResponse for " + DIFF_DL + " as ADMIN", delAcctResp);
try {
domAdminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyDistributionListRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Get this instead of "no such distribution list" because modify by ID (not name) and for domain admin
// cannot know whether that ID was for a domain we administered or not.
checkSoapReason(sfe, "permission denied: can not access distribution list ");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestFilterExisting method testBatchSize.
/**
* Confirms that we're enforcing {@code zimbraFilterBatchSize}.
*/
@Test
public void testBatchSize() throws Exception {
TestUtil.getAccount(USER_NAME).setFilterBatchSize(1);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String subject = NAME_PREFIX + " testBatchSize flag";
String msg1Id = TestUtil.addMessage(mbox, subject + " 1");
String msg2Id = TestUtil.addMessage(mbox, subject + " 2");
try {
runRules(new String[] { FLAG_RULE_NAME }, null, "subject: \'" + subject + "\'");
Assert.fail("Batch size was not enforced");
} catch (SoapFaultException e) {
String msg = e.getMessage();
Assert.assertTrue(msg.contains("2 messages"));
Assert.assertTrue(msg.contains("limit of 1"));
}
// Make sure the rule was not executed.
ZMessage msg = mbox.getMessageById(msg1Id);
if (msg.hasFlags()) {
Assert.assertFalse(msg.getFlags().contains("f"));
}
msg = mbox.getMessageById(msg2Id);
if (msg.hasFlags()) {
Assert.assertFalse(msg.getFlags().contains("f"));
}
}
Aggregations