Search in sources :

Example 86 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestDiscoverRights method granteeAll.

@Test
public void granteeAll() throws Exception {
    Domain testDomain = provUtil.createDomain(genDomainName(domain.getName()));
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), testDomain);
    String RIGHT_NAME = Right.RT_createDistList;
    prov.grantRight(TargetType.domain.getCode(), TargetBy.name, testDomain.getName(), GranteeType.GT_AUTHUSER.getCode(), null, null, null, RIGHT_NAME, null);
    SoapTransport transport = authUser(acct.getName());
    DiscoverRightsRequest req = new DiscoverRightsRequest(Collections.singletonList(RIGHT_NAME));
    DiscoverRightsResponse resp = invokeJaxb(transport, req);
    List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
    List<String> result = Lists.newArrayList();
    for (DiscoverRightsInfo rightInfo : rightsInfo) {
        List<DiscoverRightsTarget> targets = rightInfo.getTargets();
        for (DiscoverRightsTarget target : targets) {
            String id = target.getId();
            String name = target.getName();
            result.add(Verify.makeResultStr(id, name));
        }
    }
    Verify.verifyEquals(Lists.newArrayList(Verify.makeResultStr(testDomain.getId(), testDomain.getName())), result);
    provUtil.deleteAccount(acct);
    provUtil.deleteDomain(testDomain);
}
Also used : Account(com.zimbra.cs.account.Account) DiscoverRightsRequest(com.zimbra.soap.account.message.DiscoverRightsRequest) DiscoverRightsInfo(com.zimbra.soap.account.type.DiscoverRightsInfo) DiscoverRightsResponse(com.zimbra.soap.account.message.DiscoverRightsResponse) DiscoverRightsTarget(com.zimbra.soap.account.type.DiscoverRightsTarget) Domain(com.zimbra.cs.account.Domain) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 87 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestGetSignature method getSignaturePlainSig.

@Test
public void getSignaturePlainSig() throws Exception {
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
    boolean csrfEnabled = Boolean.FALSE;
    SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.FALSE);
    String sigContent = "xss&lt;script&gt;alert(\"XSS\")&lt;/script&gt;&lt;a href=javascript:alert(\"XSS\")&gt;&lt;";
    Signature sig = new Signature(null, "testSig", sigContent, "text/plain");
    CreateSignatureRequest req = new CreateSignatureRequest(sig);
    SoapProtocol proto = SoapProtocol.Soap12;
    Element sigReq = JaxbUtil.jaxbToElement(req, proto.getFactory());
    try {
        Element element = transport.invoke(sigReq, false, false, null);
        String sigt = element.getElement("signature").getAttribute("id");
        assertNotNull(sigt);
    } catch (SoapFaultException e) {
        e.printStackTrace();
        assertNull(e);
    }
    GetSignaturesRequest getSigReq = new GetSignaturesRequest();
    sigReq = JaxbUtil.jaxbToElement(getSigReq, proto.getFactory());
    try {
        Element element = transport.invoke(sigReq, false, false, null);
        String sigtContent = element.getElement("signature").getElement("content").getText();
        assertNotNull(sigContent);
        int index = sigtContent.indexOf("alert(\"XSS\")");
        Assert.assertTrue(index > -1);
    } catch (SoapFaultException e) {
        e.printStackTrace();
        assertNull(e);
    }
}
Also used : Account(com.zimbra.cs.account.Account) CreateSignatureRequest(com.zimbra.soap.account.message.CreateSignatureRequest) GetSignaturesRequest(com.zimbra.soap.account.message.GetSignaturesRequest) Signature(com.zimbra.soap.account.type.Signature) Element(com.zimbra.common.soap.Element) SoapProtocol(com.zimbra.common.soap.SoapProtocol) SoapTransport(com.zimbra.common.soap.SoapTransport) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 88 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class GalTestUtil method createAndSyncGalSyncAccount.

static void createAndSyncGalSyncAccount(String galSyncAcctName, String domainName, GSAType type) throws Exception {
    String dataSourceName;
    String dataSourceType;
    String folderName;
    if (type == GSAType.zimbra || type == GSAType.both) {
        dataSourceName = "zimbra";
        dataSourceType = "zimbra";
        folderName = "zimbra-gal-contacts";
    } else {
        dataSourceName = "external";
        dataSourceType = "ldap";
        folderName = "external-gal-contacts";
    }
    SoapTransport transport = TestUtil.getAdminSoapTransport();
    // 
    // create gal sync account and data sources, then force sync
    // 
    String gsaZimbraId = GalTestUtil.createGalSyncAccountOrDataSource(transport, galSyncAcctName, domainName, dataSourceName, dataSourceType, folderName);
    GalTestUtil.syncGASDataSource(transport, gsaZimbraId, dataSourceName);
    if (type == GSAType.both) {
        dataSourceName = "external";
        dataSourceType = "ldap";
        folderName = "external-gal-contacts";
        GalTestUtil.createGalSyncAccountOrDataSource(transport, galSyncAcctName, domainName, dataSourceName, dataSourceType, folderName);
        GalTestUtil.syncGASDataSource(transport, gsaZimbraId, dataSourceName);
    }
    // 
    // index the gal sync account (otherwise the first search will fail)
    // 
    Element eReIndex = Element.create(transport.getRequestProtocol(), AdminConstants.REINDEX_REQUEST);
    eReIndex.addAttribute(AdminConstants.A_ACTION, "start");
    Element eMbox = eReIndex.addElement(AdminConstants.E_MAILBOX);
    eMbox.addAttribute(AdminConstants.A_ID, gsaZimbraId);
    transport.invoke(eReIndex);
    // wait for the reindex to finish
    Thread.sleep(2000);
}
Also used : Element(com.zimbra.common.soap.Element) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 89 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestAuth method soapByCookie.

@Test
public void soapByCookie() throws Exception {
    boolean isAdmin = false;
    String USER_NAME = TestUtil.getAddress("user1");
    String authToken = getAuthToken(USER_NAME, isAdmin);
    Element req = Element.create(SoapProtocol.Soap12, AccountConstants.GET_INFO_REQUEST);
    SoapTransport transport = new AuthTokenInCookieTransport(authToken, isAdmin);
    Element resp = transport.invoke(req);
    Element eName = resp.getElement(AccountConstants.E_NAME);
    String value = eName.getText();
    assertEquals(USER_NAME, value);
}
Also used : Element(com.zimbra.common.soap.Element) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)89 Test (org.junit.Test)69 Account (com.zimbra.cs.account.Account)38 Element (com.zimbra.common.soap.Element)24 Group (com.zimbra.cs.account.Group)23 ServiceException (com.zimbra.common.service.ServiceException)18 SoapFaultException (com.zimbra.common.soap.SoapFaultException)16 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)12 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)12 AccountServiceException (com.zimbra.cs.account.AccountServiceException)11 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)11 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)10 ArrayList (java.util.ArrayList)10 SoapProtocol (com.zimbra.common.soap.SoapProtocol)9 Bug (com.zimbra.qa.QA.Bug)9 CreateSignatureRequest (com.zimbra.soap.account.message.CreateSignatureRequest)9 Signature (com.zimbra.soap.account.type.Signature)9 Domain (com.zimbra.cs.account.Domain)8 GetDistributionListRequest (com.zimbra.soap.account.message.GetDistributionListRequest)8 GetDistributionListResponse (com.zimbra.soap.account.message.GetDistributionListResponse)6