Search in sources :

Example 11 with Attr

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

the class TestDomainAdmin method createAdminConsoleStyleDomainAdmin.

public String createAdminConsoleStyleDomainAdmin(String domAdminName) throws ServiceException {
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "accountListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "downloadsView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "DLListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "aliasListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "resourceListView"));
    attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "saveSearch"));
    CreateAccountRequest caReq = new CreateAccountRequest(domAdminName, TestUtil.DEFAULT_PASSWORD, attrs);
    CreateAccountResponse caResp = adminSoapProv.invokeJaxb(caReq);
    assertNotNull("CreateAccountResponse for " + domAdminName, caResp);
    grantRight(adminSoapProv, TargetType.domain, ADMINISTERED_DOMAIN, domAdminName, RightConsts.RT_domainAdminConsoleRights);
    grantRight(adminSoapProv, TargetType.global, "globalacltarget", domAdminName, RightConsts.RT_domainAdminZimletRights);
    grantRight(adminSoapProv, TargetType.global, "globalacltarget", domAdminName, RightConsts.RT_adminLoginCalendarResourceAs);
    adminSoapProv.flushCache(CacheEntryType.acl, null);
    return caResp.getAccount().getId();
}
Also used : CreateAccountRequest(com.zimbra.soap.admin.message.CreateAccountRequest) CreateAccountResponse(com.zimbra.soap.admin.message.CreateAccountResponse) Attr(com.zimbra.soap.admin.type.Attr)

Example 12 with Attr

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

the class TestJaxbProvisioning method doRenameDynamicGroupTest.

private void doRenameDynamicGroupTest(boolean isACLGroup, String displayName, String memberURL) throws ServiceException {
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr("zimbraIsACLGroup", isACLGroup ? "TRUE" : "FALSE"));
    attrs.add(new Attr("zimbraMailStatus", "enabled"));
    attrs.add(new Attr("displayName", displayName));
    if (memberURL != null) {
        attrs.add(new Attr("memberURL", memberURL));
    }
    Domain dom = ensureDomainExists(testDlDomain);
    assertNotNull(String.format("Domain for %s", testDlDomain), dom);
    deleteDlIfExists(testDl);
    CreateDistributionListResponse cdlResp = prov.invokeJaxb(new CreateDistributionListRequest(testDl, attrs, true));
    assertNotNull("CreateDistributionListResponse", cdlResp);
    RenameDistributionListResponse rdlResp = prov.invokeJaxb(new RenameDistributionListRequest(cdlResp.getDl().getId(), testDlNewName));
    assertNotNull("RenameDistributionListResponse", rdlResp);
}
Also used : RenameDistributionListResponse(com.zimbra.soap.admin.message.RenameDistributionListResponse) RenameDistributionListRequest(com.zimbra.soap.admin.message.RenameDistributionListRequest) CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) Domain(com.zimbra.cs.account.Domain) Attr(com.zimbra.soap.admin.type.Attr)

Example 13 with Attr

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

the class JaxbToElementTest method jaxbSubclassFixupTest.

/**
     * Check that @{link JaxbUtil.elementToJaxb} will accept XML where
     * JAXB expects various attributes that have been specified as elements.
     * Ensure that attributes in elements of superclasses are handled
     * In this case:
     *                  <a><n>attrName1</n></a>
     * should be recognised as meaning:
     *                  <a n="attrName1"></a>
     * @throws Exception
     */
@Test
public void jaxbSubclassFixupTest() throws Exception {
    Element rootElem = Element.XMLElement.mFactory.createElement(AdminConstants.CREATE_ACCOUNT_REQUEST);
    // JAXB Attribute E_NAME
    rootElem.addNonUniqueElement(AdminConstants.E_NAME).addText("acctName");
    // JAXB Attribute E_PASSWORD
    rootElem.addNonUniqueElement(AdminConstants.E_PASSWORD).addText("AcctPassword");
    // JAXB Element E_A ---> Attr (actually a List)
    Element a1 = rootElem.addNonUniqueElement(AdminConstants.E_A);
    // JAXB Attribute A_N
    a1.addNonUniqueElement(AdminConstants.A_N).addText("attrName1");
    // value can't be set when we've specified an attribute as an element
    CreateAccountRequest req = JaxbUtil.elementToJaxb(rootElem);
    Assert.assertEquals("Account name", "acctName", req.getName());
    Assert.assertEquals("Account Password", "AcctPassword", req.getPassword());
    List<Attr> attrs = req.getAttrs();
    Assert.assertEquals("Number of attrs", 1, attrs.size());
    Assert.assertEquals("attr 1 name", "attrName1", attrs.get(0).getKey());
    Assert.assertEquals("attr 1 value", "", attrs.get(0).getValue());
}
Also used : CreateAccountRequest(com.zimbra.soap.admin.message.CreateAccountRequest) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) JAXBElement(javax.xml.bind.JAXBElement) Attr(com.zimbra.soap.admin.type.Attr) Test(org.junit.Test)

Example 14 with Attr

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

the class TestDomainAdmin method testGetCalendarResourceInDiffDomain.

@Test
public void testGetCalendarResourceInDiffDomain() 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, "testGetCalendarResourceInDiffDomain 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;
    try {
        caResp = domAdminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
        fail("CreateCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: need right: createCalendarResource for domain");
    }
    caResp = adminSoapProv.invokeJaxb(new CreateCalendarResourceRequest(DIFF_CALRES, TestUtil.DEFAULT_PASSWORD, attrs));
    assertNotNull("CreateCalendarResourceResponse for " + DIFF_CALRES + " simple as domAdmin", caResp);
    String acctId = caResp.getCalResource().getId();
    GetCalendarResourceRequest getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES), true);
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxbOnTargetAccount(getAcctReq, acctId);
        fail("GetCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    // try non-existent
    getAcctReq = new GetCalendarResourceRequest(CalendarResourceSelector.fromName(DIFF_CALRES2), true);
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetCalendarResourceRequest succeeded for non-existent account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxb(new RenameCalendarResourceRequest(acctId, TARGET_CALRES_RENAMED));
        fail("RenameCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
    try {
        domAdminSoapProv.invokeJaxb(new DeleteCalendarResourceRequest(acctId));
        fail("DeleteCalendarResourceRequest succeeded for account in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access calendar resource ");
    }
}
Also used : DeleteCalendarResourceRequest(com.zimbra.soap.admin.message.DeleteCalendarResourceRequest) GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) RenameCalendarResourceRequest(com.zimbra.soap.admin.message.RenameCalendarResourceRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateCalendarResourceResponse(com.zimbra.soap.admin.message.CreateCalendarResourceResponse) Attr(com.zimbra.soap.admin.type.Attr) CreateCalendarResourceRequest(com.zimbra.soap.admin.message.CreateCalendarResourceRequest) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 15 with Attr

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

the class TestDomainAdmin method testViaGroupDelegatedAdminAssignSendToDistList.

/**
     * Test that delegated admin with adminConsoleDLACLTabRights can grant sendToDistList right
     * @throws Exception
     */
@Test
public void testViaGroupDelegatedAdminAssignSendToDistList() throws Exception {
    String domAdminGroupId = createAdminConsoleStyleDomainAdminGroup(DOMADMINGROUP);
    CreateAccountResponse caResp;
    List<Attr> attrs = Lists.newArrayList();
    attrs.add(new Attr(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE"));
    CreateAccountRequest caReq = new CreateAccountRequest(DOMADMIN, TestUtil.DEFAULT_PASSWORD, attrs);
    caResp = adminSoapProv.invokeJaxb(caReq);
    assertNotNull("CreateAccountResponse for " + DOMADMIN + " Admin", caResp);
    AddDistributionListMemberResponse adlmResp;
    adlmResp = adminSoapProv.invokeJaxb(new AddDistributionListMemberRequest(domAdminGroupId, Lists.newArrayList(DOMADMIN)));
    assertNotNull("AddDistributionListMemberResponse for " + DOMADMIN + " Admin", adlmResp);
    adminSoapProv.createAccount(TARGET_ACCT, TestUtil.DEFAULT_PASSWORD, null);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    CreateDistributionListResponse cdlResp;
    cdlResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL));
    assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", cdlResp);
    cdlResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL));
    assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", cdlResp);
    failToGrantRight(domAdminSoapProv, TargetType.dl, TARGET_DL, TARGET_ACCT, RightConsts.RT_sendToDistList, "permission denied: insufficient right to grant 'sendToDistList' right");
    grantRight(adminSoapProv, TargetType.domain, ADMINISTERED_DOMAIN, GranteeType.grp, DOMADMINGROUP, RightConsts.RT_adminConsoleDLACLTabRights);
    grantRight(domAdminSoapProv, TargetType.dl, TARGET_DL, TARGET_ACCT, RightConsts.RT_sendToDistList);
    /* Check that doesn't allow it for a dl in a different domain */
    failToGrantRight(domAdminSoapProv, TargetType.dl, DIFF_DL, TARGET_ACCT, RightConsts.RT_sendToDistList, "permission denied: insufficient right to grant 'sendToDistList' right");
}
Also used : CreateAccountResponse(com.zimbra.soap.admin.message.CreateAccountResponse) CreateAccountRequest(com.zimbra.soap.admin.message.CreateAccountRequest) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) AddDistributionListMemberRequest(com.zimbra.soap.admin.message.AddDistributionListMemberRequest) CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) Attr(com.zimbra.soap.admin.type.Attr) Test(org.junit.Test)

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