Search in sources :

Example 6 with ModifyAccountRequest

use of com.zimbra.soap.admin.message.ModifyAccountRequest in project zm-mailbox by Zimbra.

the class TestPurgeDataSource method setPurgeParams.

private void setPurgeParams(boolean purgeEnabled, long dsQuota, long totalQuota) throws Exception {
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraFeatureDataSourcePurgingEnabled, purgeEnabled ? ProvisioningConstants.TRUE : ProvisioningConstants.FALSE);
    attrs.put(Provisioning.A_zimbraDataSourceQuota, String.valueOf(dsQuota));
    attrs.put(Provisioning.A_zimbraDataSourceTotalQuota, String.valueOf(totalQuota));
    ModifyAccountRequest modifyRequest = new ModifyAccountRequest(account.getId());
    modifyRequest.setAttrs(attrs);
    SoapTest.invokeJaxb(transport, modifyRequest);
}
Also used : HashMap(java.util.HashMap) ModifyAccountRequest(com.zimbra.soap.admin.message.ModifyAccountRequest)

Example 7 with ModifyAccountRequest

use of com.zimbra.soap.admin.message.ModifyAccountRequest 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 8 with ModifyAccountRequest

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

Aggregations

ModifyAccountRequest (com.zimbra.soap.admin.message.ModifyAccountRequest)8 SoapFaultException (com.zimbra.common.soap.SoapFaultException)5 Attr (com.zimbra.soap.admin.type.Attr)5 Test (org.junit.Test)5 Account (com.zimbra.cs.account.Account)3 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)3 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)2 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)2 ModifyAccount (com.zimbra.cs.service.admin.ModifyAccount)2 DeleteAccountRequest (com.zimbra.soap.admin.message.DeleteAccountRequest)2 DeleteAccountResponse (com.zimbra.soap.admin.message.DeleteAccountResponse)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Element (com.zimbra.common.soap.Element)1 AuthToken (com.zimbra.cs.account.AuthToken)1 Provisioning (com.zimbra.cs.account.Provisioning)1 Server (com.zimbra.cs.account.Server)1 AdminSession (com.zimbra.cs.session.AdminSession)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 ModifyAccountResponse (com.zimbra.soap.admin.message.ModifyAccountResponse)1