use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testGetCalendarResourceInDomAdminDomain.
@Test
public void testGetCalendarResourceInDomAdminDomain() 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, "testGetCalendarResourceInDomAdminDomain 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();
GetCalendarResourceResponse getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true));
assertNotNull("GetCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", getAcctResp);
getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true), acctId);
assertNotNull("GetCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", getAcctResp);
RenameCalendarResourceResponse renAResp;
renAResp = domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
assertNotNull("RenameCalendarResourceResponse for " + TARGET_CALRES + " simple as domAdmin", renAResp);
renAResp = domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES));
assertNotNull("RenameCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", renAResp);
DeleteCalendarResourceRequest delAcctReq;
DeleteCalendarResourceResponse delAcctResp;
delAcctReq = new DeleteCalendarResourceRequest(null);
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
fail("DeleteCalendarResouceRequest succeeded in spite of having no 'id' specified!!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
delAcctReq = new DeleteCalendarResourceRequest(acctId);
delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
assertNotNull("DeleteCalendarResourceResponse for " + TARGET_CALRES + " as domAdmin specifying target acct", delAcctResp);
try {
getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true));
fail("GetCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "no such calendar resource: ");
}
try {
getAcctResp = domAdminSoapProv.invokeJaxb(new GetCalendarResourceRequest(CalendarResourceSelector.fromId(acctId), true));
fail("GetCalendarResourceRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// because by id not name
checkSoapReason(sfe, "permission denied: can not access calendar resource ");
}
try {
getAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(new GetCalendarResourceRequest(CalendarResourceSelector.fromName(TARGET_CALRES), true), acctId);
fail("GetCalendarResourceRequest 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 testModifyAccountInDiffDomain.
@Test
public void testModifyAccountInDiffDomain() throws Exception {
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
Account acct = TestJaxbProvisioning.ensureAccountExists(DIFF_ACCT);
String acctId = acct.getId();
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
ModifyAccountRequest modAcctReq = new ModifyAccountRequest(acctId);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
try {
domAdminSoapProv.invokeJaxb(modAcctReq);
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
DeleteAccountRequest delAcctReq = new DeleteAccountRequest(acctId);
DeleteAccountResponse delAcctResp = adminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
assertNotNull("DeleteAccountResponse for " + DIFF_ACCT + " as ADMIN specifying target acct", delAcctResp);
try {
domAdminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Get this instead of "no such account: " 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 account ");
}
try {
domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
fail("ModifyAccountRequest 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 failToGrantRight.
private void failToGrantRight(SoapProvisioning soapProv, TargetType targetType, String targetName, String granteeName, String rightName, String expectedFailureReason) throws ServiceException {
GranteeSelector grantee;
EffectiveRightsTargetSelector target;
RightModifierInfo right;
grantee = new GranteeSelector(GranteeType.usr, GranteeBy.name, granteeName);
target = new EffectiveRightsTargetSelector(targetType, TargetBy.name, targetName);
right = new RightModifierInfo(rightName);
try {
soapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
fail(String.format("granting %s right succeeded when it shouldn't have", rightName));
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, expectedFailureReason);
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testModifyAccountInDomAdminDomain.
@Test
public void testModifyAccountInDomAdminDomain() throws Exception {
Account acct = TestJaxbProvisioning.ensureAccountExists(TARGET_ACCT);
String acctId = acct.getId();
String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
ModifyAccountRequest modAcctReq;
ModifyAccountResponse modAcctResp;
modAcctReq = new ModifyAccountRequest(null);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
try {
modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyAccountRequest succeeded without 'id'!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "invalid request: missing required attribute: id");
}
modAcctReq = new ModifyAccountRequest(acctId);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "dummy description"));
modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
assertNotNull("ModifyAccountResponse for " + TARGET_ACCT + " simple as domAdmin", modAcctResp);
modAcctReq = new ModifyAccountRequest(acctId);
modAcctReq.addAttr(new Attr(Provisioning.A_description, "another dummy description"));
modAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
assertNotNull("ModifyAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", modAcctResp);
DeleteAccountRequest delAcctReq = new DeleteAccountRequest(acctId);
DeleteAccountResponse delAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(delAcctReq, acctId);
assertNotNull("DeleteAccountResponse for " + TARGET_ACCT + " as domAdmin specifying target acct", delAcctResp);
try {
modAcctResp = domAdminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Get this instead of "no such account: " 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 account ");
}
try {
modAcctResp = domAdminSoapProv.invokeJaxbOnTargetAccount(modAcctReq, acctId);
fail("ModifyAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
checkSoapReason(sfe, "permission denied: can not access account ");
}
// as full admin
try {
modAcctResp = adminSoapProv.invokeJaxb(modAcctReq);
fail("ModifyAccountRequest succeeded after delete!");
} catch (SoapFaultException sfe) {
// Full admin gets "no such account: " instead of "permission denied"
checkSoapReason(sfe, "no such account: ");
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method testDestroyWaitset.
@Test
public void testDestroyWaitset() throws Exception {
ZimbraLog.test.info("Starting testDestroyWaitset");
String user1Name = "testDestroyWaitset_user1";
acc1 = TestUtil.createAccount(user1Name);
ZMailbox mbox = TestUtil.getZMailbox(user1Name);
Set<String> accountIds = new HashSet<String>();
accountIds.add(mbox.getAccountId());
String adminAuthToken = TestUtil.getAdminSoapTransport().getAuthToken().getValue();
AdminCreateWaitSetResponse resp = createAdminWaitSet(accountIds, adminAuthToken, false);
assertNotNull(resp);
waitSetId = resp.getWaitSetId();
assertNotNull(waitSetId);
QueryWaitSetRequest qwsReq = new QueryWaitSetRequest(waitSetId);
QueryWaitSetResponse qwsResp = (QueryWaitSetResponse) sendReq(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl());
validateQueryWaitSetResponse(qwsResp, acc1.getId(), null, null, false);
AdminDestroyWaitSetRequest destroyReq = new AdminDestroyWaitSetRequest(waitSetId);
AdminDestroyWaitSetResponse destroyResp = (AdminDestroyWaitSetResponse) sendReq(destroyReq, adminAuthToken, TestUtil.getAdminSoapUrl());
assertNotNull("AdminDestroyWaitSetResponse should not be null", destroyResp);
assertNotNull("AdminDestroyWaitSetResponse::waitSetId should not be null", destroyResp.getWaitSetId());
assertEquals("AdminDestroyWaitSetResponse has wrong waitSetId", waitSetId, destroyResp.getWaitSetId());
qwsReq = new QueryWaitSetRequest(waitSetId);
Element faultResp = sendReqExpectedToFail(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
assertNotNull("should return Element", faultResp);
try {
TestUtil.getAdminSoapTransport().extractBodyElement(faultResp);
fail("Should thrown SoapFaultException");
} catch (SoapFaultException sfe) {
assertEquals("Expecting admin.NO_SUCH_WAITSET", AdminServiceException.NO_SUCH_WAITSET, sfe.getCode());
} catch (SoapParseException spe) {
fail("Should not be throwing SoapParseException. " + spe.getMessage());
}
waitSetId = null;
}
Aggregations