use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestCountObjects method testOnlyRelated.
@Test
public void testOnlyRelated() throws Exception {
try {
SoapTransport transport = SoapTest.authAdmin(DELEGATED_ADMIN_USER_EMAIL, PASSWORD);
// count only related domains
try {
CountObjectsRequest req = new CountObjectsRequest(CountObjectsType.domain);
req.setOnlyRelated(true);
CountObjectsResponse resp = SoapTest.invokeJaxb(transport, req);
assertTrue("should have exactly one account", resp.getNum() == 1);
assertEquals("object type in response should be 'domain'", "domain", resp.getType());
} catch (SoapFaultException e) {
fail("should not be fail");
}
// count domain without necessary right
try {
CountObjectsRequest req = new CountObjectsRequest(CountObjectsType.domain);
CountObjectsResponse resp = SoapTest.invokeJaxb(transport, req);
fail("should not be able to count domains");
} catch (SoapFaultException e) {
assertEquals(ServiceException.PERM_DENIED, e.getCode());
}
// count domain with countDomain right
try {
mProv.grantRight(TargetType.global.getCode(), null, null, com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeBy.name, DELEGATED_ADMIN_USER_EMAIL, null, RightConsts.RT_countDomain, null);
CountObjectsRequest req = new CountObjectsRequest(CountObjectsType.domain);
CountObjectsResponse resp = SoapTest.invokeJaxb(transport, req);
assertTrue("should have at least 2 domain", resp.getNum() > 1);
assertEquals("object type in response should be 'domain'", "domain", resp.getType());
} catch (SoapFaultException e) {
fail("should not be fail");
}
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestAuthentication method testAccessInactiveAccount.
/**
* Attempts to access a deleted account and confirms that the attempt
* fails with an auth error.
*/
public void testAccessInactiveAccount() throws Exception {
// Log in and check the inbox
LmcSession session = TestUtil.getSoapSession(USER_NAME);
LmcSearchRequest req = new LmcSearchRequest();
req.setQuery("in:inbox");
req.setSession(session);
req.invoke(TestUtil.getSoapUrl());
// Deactivate the account
Account account = getAccount();
mProv.modifyAccountStatus(account, Provisioning.ACCOUNT_STATUS_MAINTENANCE);
// Submit another request and make sure it fails with an auth error
try {
req.invoke(TestUtil.getSoapUrl());
} catch (SoapFaultException ex) {
String substring = "auth credentials have expired";
String msg = String.format("Error message '%s' does not contain '%s'", ex.getMessage(), substring);
assertTrue(msg, ex.getMessage().contains(substring));
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestAuthentication method testAccessDeletedAccount.
/**
* Attempts to access a deleted account and confirms that the attempt
* fails with an auth error.
*/
public void testAccessDeletedAccount() throws Exception {
// Log in and check the inbox
LmcSession session = TestUtil.getSoapSession(USER_NAME);
LmcSearchRequest req = new LmcSearchRequest();
req.setQuery("in:inbox");
req.setSession(session);
req.invoke(TestUtil.getSoapUrl());
// Delete the account
Account account = getAccount();
assertNotNull("Account does not exist", account);
mProv.deleteAccount(account.getId());
// Submit another request and make sure it fails with an auth error
try {
req.invoke(TestUtil.getSoapUrl());
} catch (SoapFaultException ex) {
assertTrue("Unexpected error: " + ex.getMessage(), ex.getMessage().indexOf("auth credentials have expired") >= 0);
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestSendAndReceive method testDomainSmtpSettings.
/**
* Confirms that domain SMTP settings override server settings (bug 28442).
*/
@Test
public void testDomainSmtpSettings() throws Exception {
TestUtil.createAccount(USER_NAME);
// Send a message using the user's default SMTP settings.
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String subject = NAME_PREFIX + " testDomainSmtpSettings 1";
TestUtil.sendMessage(mbox, USER_NAME, subject);
TestUtil.waitForMessage(mbox, "in:inbox subject:\"" + subject + "\"");
// Set domain SMTP port to a bogus value and confirm that the send fails.
TestUtil.setDomainAttr(USER_NAME, Provisioning.A_zimbraSmtpPort, "35");
subject = NAME_PREFIX + " testDomainSmtpSettings 2";
boolean sendFailed = false;
try {
TestUtil.sendMessage(mbox, USER_NAME, subject);
} catch (SoapFaultException e) {
Assert.assertEquals(MailServiceException.TRY_AGAIN, e.getCode());
sendFailed = true;
}
Assert.assertTrue("Message send should have failed", sendFailed);
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestSoap method testSoapRequestMaxSize.
@Test
public void testSoapRequestMaxSize() throws Exception {
StringBuilder messageBody = new StringBuilder();
for (int i = 1; i <= 100; i++) {
messageBody.append("Morey Amsterdam was a great man. Morey Amsterdam was not a sandwich.\r\n");
}
setSoapRequestMaxSize(100000);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
TestUtil.sendMessage(mbox, USER_NAME, NAME_PREFIX + " 1", messageBody.toString());
setSoapRequestMaxSize(1000);
try {
TestUtil.sendMessage(mbox, USER_NAME, NAME_PREFIX + " 2", messageBody.toString());
Assert.fail("SOAP request should not have succeeded.");
} catch (SoapFaultException e) {
Assert.assertTrue("Unexpected error: " + e.toString(), e.toString().contains("bytes set for zimbraSoapRequestMaxSize"));
}
}
Aggregations