Search in sources :

Example 1 with GetInfoResponse

use of com.zimbra.soap.account.message.GetInfoResponse in project zm-mailbox by Zimbra.

the class JaxbToElementTest method JSONelementToJaxbUsingDom4jTest.

/*
     * This seems to work fine, although similar code in JAXB enabled ExportContacts server-side does not - get:
     *   javax.xml.bind.UnmarshalException: Namespace URIs and local names to the unmarshaller needs to be interned.
     */
@SuppressWarnings("deprecation")
public // Disabled @Test
void JSONelementToJaxbUsingDom4jTest() throws Exception {
    for (int cnt = 1; cnt <= 4; cnt++) {
        Element env = Element.parseJSON(getInfoResponseJSONwithEnv);
        Element el = env.listElements().get(0);
        GetInfoResponse getInfoResp = JaxbUtil.elementToJaxbUsingDom4j(el);
        Assert.assertEquals("Account name", "user1@tarka.local", getInfoResp.getAccountName());
    }
}
Also used : GetInfoResponse(com.zimbra.soap.account.message.GetInfoResponse) 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)

Example 2 with GetInfoResponse

use of com.zimbra.soap.account.message.GetInfoResponse in project zm-mailbox by Zimbra.

the class JaxbToElementTest method elementToJaxbTest.

@Test
public void elementToJaxbTest() throws Exception {
    Element el = JaxbUtil.jaxbToElement(getInfoRespJaxb);
    org.w3c.dom.Document doc = el.toW3cDom();
    ZimbraLog.test.debug("(XML)elementToJaxbTest toW3cDom() Xml:\n%s", W3cDomUtil.asXML(doc));
    for (int cnt = 1; cnt <= iterationNum; cnt++) {
        GetInfoResponse getInfoResp = JaxbUtil.elementToJaxb(getInfoRespElem);
        Assert.assertEquals("Account name", "user1@tarka.local", getInfoResp.getAccountName());
    }
}
Also used : GetInfoResponse(com.zimbra.soap.account.message.GetInfoResponse) 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) Test(org.junit.Test)

Example 3 with GetInfoResponse

use of com.zimbra.soap.account.message.GetInfoResponse in project zm-mailbox by Zimbra.

the class JaxbToElementTest method JSONelementToJaxbTest.

@Test
public void JSONelementToJaxbTest() throws Exception {
    Element env = Element.parseJSON(getInfoResponseJSONwithEnv);
    Element el = env.listElements().get(0);
    org.w3c.dom.Document doc = el.toW3cDom();
    ZimbraLog.test.debug("JSONelementToJaxbTest toW3cDom Xml:\n%s", W3cDomUtil.asXML(doc));
    GetInfoResponse getInfoResp = JaxbUtil.elementToJaxb(el);
    Assert.assertEquals("Account name", "user1@tarka.local", getInfoResp.getAccountName());
}
Also used : GetInfoResponse(com.zimbra.soap.account.message.GetInfoResponse) 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) Test(org.junit.Test)

Example 4 with GetInfoResponse

use of com.zimbra.soap.account.message.GetInfoResponse in project zm-mailbox by Zimbra.

the class TestGetInfo method discoverRights.

@Test
public void discoverRights() throws Exception {
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
    Group group = provUtil.createGroup(genGroupNameLocalPart(), domain, false);
    prov.grantRight(TargetType.domain.getCode(), TargetBy.name, domain.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, User.R_createDistList.getName(), null);
    prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, User.R_sendToDistList.getName(), null);
    SoapTransport transport = authUser(acct.getName());
    GetInfoRequest req = new GetInfoRequest();
    req.addRight(User.R_createDistList.getName());
    req.addRight(User.R_sendToDistList.getName());
    GetInfoResponse resp = invokeJaxb(transport, req);
    List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
    Set<String> result = Sets.newHashSet();
    for (DiscoverRightsInfo rightInfo : rightsInfo) {
        String right = rightInfo.getRight();
        List<DiscoverRightsTarget> targets = rightInfo.getTargets();
        for (DiscoverRightsTarget target : targets) {
            String id = target.getId();
            String name = target.getName();
            String type = target.getType().toString();
            result.add(Verify.makeResultStr(right, id, name, type));
        }
    }
    Verify.verifyEquals(Sets.newHashSet(Verify.makeResultStr(User.R_createDistList.getName(), domain.getId(), domain.getName(), TargetType.domain.getCode()), Verify.makeResultStr(User.R_sendToDistList.getName(), group.getId(), group.getName(), TargetType.dl.getCode())), result);
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) GetInfoResponse(com.zimbra.soap.account.message.GetInfoResponse) DiscoverRightsInfo(com.zimbra.soap.account.type.DiscoverRightsInfo) DiscoverRightsTarget(com.zimbra.soap.account.type.DiscoverRightsTarget) GetInfoRequest(com.zimbra.soap.account.message.GetInfoRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 5 with GetInfoResponse

use of com.zimbra.soap.account.message.GetInfoResponse in project zm-mailbox by Zimbra.

the class TestAuth method accountStatusMaintenanceAfterAuth.

@Test
public void accountStatusMaintenanceAfterAuth() throws Exception {
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
    SoapTransport transport = authUser(acct.getName());
    /*
         * change account status to maintenance
         */
    prov.modifyAccountStatus(acct, AccountStatus.maintenance.name());
    GetInfoRequest req = new GetInfoRequest();
    String errorCode = null;
    try {
        GetInfoResponse resp = invokeJaxb(transport, req);
    } catch (SoapFaultException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.AUTH_EXPIRED, errorCode);
    provUtil.deleteAccount(acct);
}
Also used : Account(com.zimbra.cs.account.Account) GetInfoResponse(com.zimbra.soap.account.message.GetInfoResponse) GetInfoRequest(com.zimbra.soap.account.message.GetInfoRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Aggregations

GetInfoResponse (com.zimbra.soap.account.message.GetInfoResponse)8 Test (org.junit.Test)4 Element (com.zimbra.common.soap.Element)3 JSONElement (com.zimbra.common.soap.Element.JSONElement)3 XMLElement (com.zimbra.common.soap.Element.XMLElement)3 GetInfoRequest (com.zimbra.soap.account.message.GetInfoRequest)3 JAXBElement (javax.xml.bind.JAXBElement)3 SoapTransport (com.zimbra.common.soap.SoapTransport)2 Account (com.zimbra.cs.account.Account)2 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Group (com.zimbra.cs.account.Group)1 DiscoverRightsInfo (com.zimbra.soap.account.type.DiscoverRightsInfo)1 DiscoverRightsTarget (com.zimbra.soap.account.type.DiscoverRightsTarget)1