Search in sources :

Example 21 with Attr

use of com.zimbra.soap.admin.type.Attr in project zm-mailbox by Zimbra.

the class TestServerEnumeration method testModifyCalresAsGlobalAdmin.

@Test
public void testModifyCalresAsGlobalAdmin() throws Exception {
    ModifyCalendarResourceRequest req = new ModifyCalendarResourceRequest(myCalRes.getId());
    req.addAttr(new Attr(Provisioning.A_zimbraMailHost, NON_EXISTING_SERVER));
    req.addAttr(new Attr(Provisioning.A_description, "test description"));
    try {
        adminSoapProv.invokeJaxb(req);
        fail("should have caught an exception");
    } catch (SoapFaultException e) {
        assertEquals("should be getting 'no such server' response", AccountServiceException.NO_SUCH_SERVER, e.getCode());
    }
}
Also used : ModifyCalendarResourceRequest(com.zimbra.soap.admin.message.ModifyCalendarResourceRequest) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 22 with Attr

use of com.zimbra.soap.admin.type.Attr in project zm-mailbox by Zimbra.

the class TestUtil method deleteAccount.

/**
     * Deletes the account for the given username. Consider using {@link deleteAccountIfExists} as alternative
     * to reduce logging where the account may not exist.
     */
public static void deleteAccount(String username) throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    // so that both the account and mailbox are deleted.
    if (!(prov instanceof SoapProvisioning)) {
        prov = newSoapProvisioning();
    }
    SoapProvisioning soapProv = (SoapProvisioning) prov;
    GetAccountRequest gaReq = new GetAccountRequest(AccountSelector.fromName(username), false, Lists.newArrayList(Provisioning.A_zimbraId));
    try {
        GetAccountResponse resp = soapProv.invokeJaxb(gaReq);
        if (resp != null) {
            String id = null;
            for (Attr attr : resp.getAccount().getAttrList()) {
                if (Provisioning.A_zimbraId.equals(attr.getKey())) {
                    id = attr.getValue();
                    break;
                }
            }
            if (null == id) {
                ZimbraLog.test.error("GetAccountResponse for '%s' did not contain the zimbraId", username);
            }
            prov.deleteAccount(id);
        }
    } catch (SoapFaultException sfe) {
        if (!sfe.getMessage().contains("no such account")) {
            ZimbraLog.test.error("GetAccountResponse for '%s' hit unexpected problem", username, sfe);
        }
    }
}
Also used : GetAccountResponse(com.zimbra.soap.admin.message.GetAccountResponse) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) GetAccountRequest(com.zimbra.soap.admin.message.GetAccountRequest) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) QueueAttr(com.zimbra.cs.rmgmt.RemoteMailQueue.QueueAttr) Attr(com.zimbra.soap.admin.type.Attr) SoapFaultException(com.zimbra.common.soap.SoapFaultException)

Aggregations

Attr (com.zimbra.soap.admin.type.Attr)22 Test (org.junit.Test)17 SoapFaultException (com.zimbra.common.soap.SoapFaultException)15 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)10 CreateDistributionListRequest (com.zimbra.soap.admin.message.CreateDistributionListRequest)5 CreateDistributionListResponse (com.zimbra.soap.admin.message.CreateDistributionListResponse)5 ModifyAccountRequest (com.zimbra.soap.admin.message.ModifyAccountRequest)5 ModifyCalendarResourceRequest (com.zimbra.soap.admin.message.ModifyCalendarResourceRequest)5 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)4 AdminDocumentHandler (com.zimbra.cs.service.admin.AdminDocumentHandler)4 CreateCalendarResourceRequest (com.zimbra.soap.admin.message.CreateCalendarResourceRequest)4 CreateCalendarResourceResponse (com.zimbra.soap.admin.message.CreateCalendarResourceResponse)4 DeleteCalendarResourceRequest (com.zimbra.soap.admin.message.DeleteCalendarResourceRequest)4 ArrayList (java.util.ArrayList)4 CreateAccountRequest (com.zimbra.soap.admin.message.CreateAccountRequest)3 DeleteCalendarResourceResponse (com.zimbra.soap.admin.message.DeleteCalendarResourceResponse)3 ModifyDistributionListRequest (com.zimbra.soap.admin.message.ModifyDistributionListRequest)3 Element (com.zimbra.common.soap.Element)2 Account (com.zimbra.cs.account.Account)2 ModifyAccount (com.zimbra.cs.service.admin.ModifyAccount)2