Search in sources :

Example 51 with SoapFaultException

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 ");
    }
}
Also used : GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) RenameCalendarResourceResponse(com.zimbra.soap.admin.message.RenameCalendarResourceResponse) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) GetCalendarResourceResponse(com.zimbra.soap.admin.message.GetCalendarResourceResponse) DeleteCalendarResourceResponse(com.zimbra.soap.admin.message.DeleteCalendarResourceResponse) RenameCalendarResourceRequest(com.zimbra.soap.admin.message.RenameCalendarResourceRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateCalendarResourceResponse(com.zimbra.soap.admin.message.CreateCalendarResourceResponse) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest) Test(org.junit.Test)

Example 52 with SoapFaultException

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 ");
    }
}
Also used : Account(com.zimbra.cs.account.Account) DeleteAccountRequest(com.zimbra.soap.admin.message.DeleteAccountRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) ModifyAccountRequest(com.zimbra.soap.admin.message.ModifyAccountRequest) DeleteAccountResponse(com.zimbra.soap.admin.message.DeleteAccountResponse) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 53 with SoapFaultException

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);
    }
}
Also used : RightModifierInfo(com.zimbra.soap.admin.type.RightModifierInfo) GrantRightRequest(com.zimbra.soap.admin.message.GrantRightRequest) GranteeSelector(com.zimbra.soap.admin.type.GranteeSelector) EffectiveRightsTargetSelector(com.zimbra.soap.admin.type.EffectiveRightsTargetSelector) SoapFaultException(com.zimbra.common.soap.SoapFaultException)

Example 54 with SoapFaultException

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: ");
    }
}
Also used : Account(com.zimbra.cs.account.Account) DeleteAccountRequest(com.zimbra.soap.admin.message.DeleteAccountRequest) ModifyAccountResponse(com.zimbra.soap.admin.message.ModifyAccountResponse) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) ModifyAccountRequest(com.zimbra.soap.admin.message.ModifyAccountRequest) DeleteAccountResponse(com.zimbra.soap.admin.message.DeleteAccountResponse) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 55 with SoapFaultException

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;
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) AdminDestroyWaitSetRequest(com.zimbra.soap.admin.message.AdminDestroyWaitSetRequest) QueryWaitSetResponse(com.zimbra.soap.admin.message.QueryWaitSetResponse) Element(com.zimbra.common.soap.Element) SoapParseException(com.zimbra.common.soap.SoapParseException) QueryWaitSetRequest(com.zimbra.soap.admin.message.QueryWaitSetRequest) AdminDestroyWaitSetResponse(com.zimbra.soap.admin.message.AdminDestroyWaitSetResponse) SoapFaultException(com.zimbra.common.soap.SoapFaultException) HashSet(java.util.HashSet) AdminCreateWaitSetResponse(com.zimbra.soap.admin.message.AdminCreateWaitSetResponse) Test(org.junit.Test)

Aggregations

SoapFaultException (com.zimbra.common.soap.SoapFaultException)81 Test (org.junit.Test)62 Element (com.zimbra.common.soap.Element)32 Account (com.zimbra.cs.account.Account)23 ServiceException (com.zimbra.common.service.ServiceException)15 SoapTransport (com.zimbra.common.soap.SoapTransport)15 Attr (com.zimbra.soap.admin.type.Attr)15 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)14 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)14 ZMailbox (com.zimbra.client.ZMailbox)12 SoapProtocol (com.zimbra.common.soap.SoapProtocol)11 ArrayList (java.util.ArrayList)11 DeployZimletRequest (com.zimbra.soap.admin.message.DeployZimletRequest)10 CreateSignatureRequest (com.zimbra.soap.account.message.CreateSignatureRequest)9 Signature (com.zimbra.soap.account.type.Signature)9 AttachmentIdAttrib (com.zimbra.soap.admin.type.AttachmentIdAttrib)9 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)8 Mailbox (com.zimbra.cs.mailbox.Mailbox)6 Provisioning (com.zimbra.cs.account.Provisioning)5 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)5