Search in sources :

Example 1 with ModifyAccountResponse

use of com.zimbra.soap.admin.message.ModifyAccountResponse 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)

Aggregations

SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Account (com.zimbra.cs.account.Account)1 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)1 DeleteAccountRequest (com.zimbra.soap.admin.message.DeleteAccountRequest)1 DeleteAccountResponse (com.zimbra.soap.admin.message.DeleteAccountResponse)1 ModifyAccountRequest (com.zimbra.soap.admin.message.ModifyAccountRequest)1 ModifyAccountResponse (com.zimbra.soap.admin.message.ModifyAccountResponse)1 Attr (com.zimbra.soap.admin.type.Attr)1 Test (org.junit.Test)1