use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testModifyCalendarResourceInDomAdminDomain.
@Test
public void testModifyCalendarResourceInDomAdminDomain() 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, "testModifyCalendarResourceInDomAdminDomain 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;
caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(TARGET_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
assertNotNull("CreateCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", caResp);
String acctId = caResp.getCalResource().getId();
ModifyCalendarResourceRequest modAcctReq;
ModifyCalendarResourceResponse modAcctResp;
modAcctReq = new ModifyCalendarResourceRequest(null);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
try {
modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyCalendarResourceRequest succeeded without 'id'!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
modAcctReq = new ModifyCalendarResourceRequest(acctId);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
assertNotNull("ModifyCalendarResourceResponse for " + TARGET_CALRES2 + " simple as domAdmin", modAcctResp);
modAcctReq = new ModifyCalendarResourceRequest(acctId);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "another dummy description"));
modAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
assertNotNull("ModifyCalendarResourceResponse for " + TARGET_CALRES2 + " as domAdmin specifying target acct", modAcctResp);
DeleteCalendarResourceRequest delAcctReq = new DeleteCalendarResourceRequest(acctId);
DeleteCalendarResourceResponse delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
assertNotNull("DeleteCalendarResourceResponse for " + TARGET_CALRES2 + " as domAdmin specifying target acct", delAcctResp);
try {
modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Get this instead of "no such calendar resource: " 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 calendar resource ");
}
try {
modAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
fail("ModifyCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account");
}
// as full admin
try {
modAcctResp = adminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Full admin gets "no such calendar resource: " instead of "permission denied"
checkSoapReason(sfe, "no such calendar resource: ");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetAccountInDiffDomain.
@Test
public void testGetAccountInDiffDomain() throws Exception {
Account acct = TestJaxbProvisioning.ensureAccountExists(DIFF_ACCT);
String acctId = acct.getId();
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
GetAccountRequest getAcctReq = new GetAccountRequest(AccountSelector.fromName(DIFF_ACCT), true);
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetAccountRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
fail("GetAccountRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
// try non-existent acct
getAcctReq = new GetAccountRequest(AccountSelector.fromName(DIFF_ACCT2), true);
try {
domAdminSoapProv.invokeJaxb(getAcctReq);
fail("GetAccountRequest succeeded for non-existent account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
GetMailboxRequest gmReq = new GetMailboxRequest(new MailboxByAccountIdSelector(acctId));
try {
domAdminSoapProv.invokeJaxb(gmReq);
fail("GetMailboxRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(gmReq, acctId);
fail("GetMailboxRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
AddAccountAliasResponse aaaResp;
try {
aaaResp = domAdminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
fail("AddAccountAliasRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
aaaResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT2), acctId);
fail("AddAccountAliasRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
aaaResp = adminSoapProv.invokeJaxb(new AddAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
assertNotNull("AddAccountAliasResponse for " + TARGET_ACCT + " as FULL ADMIN", aaaResp);
try {
domAdminSoapProv.invokeJaxb(new RemoveAccountAliasRequest(acctId, ALIAS_FOR_TARGET_ACCT));
fail("RemoveAccountAliasRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
domAdminSoapProv.invokeJaxb(new RenameAccountRequest(acctId, TARGET_ACCT_RENAMED));
fail("RenameAccountRequest succeeded for account in other domain!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
domAdminSoapProv.invokeJaxb(new DeleteAccountRequest(acctId));
fail("DeleteAccountRequest succeeded for account in other domain!");
} 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 testModifyDistributionListInDomAdminDomain.
@Test
public void testModifyDistributionListInDomAdminDomain() 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, "testModifyDistributionListInDomAdminDomain"));
CreateDistributionListResponse caResp;
caResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL, attrs, false));
assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", caResp);
String dlId = caResp.getDl().getId();
ModifyDistributionListRequest modDlReq;
ModifyDistributionListResponse modDlResp;
modDlReq = new ModifyDistributionListRequest(null);
modDlReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
try {
modDlResp = domAdminSoapProv.invokeJaxb(modDlReq);
fail("ModifyDistributionListRequest succeeded without specifying id!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
modDlReq = new ModifyDistributionListRequest(dlId);
modDlReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
modDlResp = domAdminSoapProv.invokeJaxb(modDlReq);
assertNotNull("ModifyDistributionListResponse for " + TARGET_DL2 + " simple as domAdmin", modDlResp);
DeleteDistributionListRequest delDlReq = new DeleteDistributionListRequest(dlId);
DeleteDistributionListResponse delDlResp = domAdminSoapProv.invokeJaxb(delDlReq);
assertNotNull("DeleteDistributionListResponse for " + TARGET_DL2 + " as domAdmin", delDlResp);
try {
modDlResp = domAdminSoapProv.invokeJaxb(modDlReq);
fail("ModifyDistributionListRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Get this instead of "no such calendar resource: " 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 ");
}
// as full admin
try {
modDlResp = adminSoapProv.invokeJaxb(modDlReq);
fail("ModifyDistributionListRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Full admin gets "no such distribution list: " instead of "permission denied"
checkSoapReason(sfe, "no such distribution list: ");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDeployZimlet method testZipWithTraversal.
@Test
public void testZipWithTraversal() 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/com_zimbra_url.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 testEmptyAid.
@Test
public void testEmptyAid() 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);
AttachmentIdAttrib att = new AttachmentIdAttrib("");
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
}
}
Aggregations