Search in sources :

Example 61 with SoapTransport

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

the class TestCsrfRequest method getCreateSigWithAuthAndCsrfEnabledAndInvalidCsrfToken.

@Test
public void getCreateSigWithAuthAndCsrfEnabledAndInvalidCsrfToken() throws Exception {
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraCsrfTokenCheckEnabled, "TRUE");
    prov.modifyAttrs(prov.getConfig(), attrs, true);
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
    boolean csrfEnabled = Boolean.TRUE;
    SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.TRUE);
    String temp = transport.getCsrfToken().substring(7);
    transport.setCsrfToken(temp);
    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/html");
    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");
        assertNull(sigt);
    } catch (SoapFaultException e) {
        assertNotNull(e);
        Assert.assertEquals(true, e.getCode().contains("AUTH_REQUIRED"));
    }
}
Also used : Account(com.zimbra.cs.account.Account) CreateSignatureRequest(com.zimbra.soap.account.message.CreateSignatureRequest) HashMap(java.util.HashMap) 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 62 with SoapTransport

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

the class TestDelegatedDL method getDistributionList.

@Test
public void getDistributionList() throws Exception {
    SoapTransport transport = authUser(USER_OWNER);
    GetDistributionListRequest req = new GetDistributionListRequest(DistributionListSelector.fromName(DL_NAME), Boolean.TRUE);
    GetDistributionListResponse resp = invokeJaxb(transport, req);
    DistributionListInfo dlInfo = resp.getDl();
    assertTrue(dlInfo.isOwner());
    assertFalse(dlInfo.isMember());
    String dlId = dlInfo.getId();
    Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
    assertNotNull(group);
    assertEquals(group.getId(), dlId);
    boolean seenMail = false;
    boolean seenSubsPolicy = false;
    boolean seenUnsubsPolicy = false;
    List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
    for (KeyValuePair attr : attrs) {
        String name = attr.getKey();
        String value = attr.getValue();
        if (Provisioning.A_mail.equals(name)) {
            assertEquals(group.getName(), value);
            seenMail = true;
        }
        if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(name)) {
            assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
            seenSubsPolicy = true;
        }
        // zimbraAccount:GetDistributionListResponse should return the default value, instead of empty.
        if (Provisioning.A_zimbraDistributionListUnsubscriptionPolicy.equals(name)) {
            assertEquals(ZAttrProvisioning.DistributionListUnsubscriptionPolicy.REJECT.name(), value);
            seenUnsubsPolicy = true;
        }
    }
    assertTrue(seenMail);
    assertTrue(seenSubsPolicy);
    assertTrue(seenUnsubsPolicy);
    List<? extends DistributionListGranteeInfoInterface> dlOwners = dlInfo.getOwners();
    assertEquals(1, dlOwners.size());
    for (DistributionListGranteeInfoInterface owner : dlOwners) {
        com.zimbra.soap.type.GranteeType type = owner.getType();
        String id = owner.getId();
        String name = owner.getName();
        assertEquals(com.zimbra.soap.type.GranteeType.usr, type);
        assertEquals(USER_OWNER, name);
    }
}
Also used : GetDistributionListResponse(com.zimbra.soap.account.message.GetDistributionListResponse) Group(com.zimbra.cs.account.Group) DistributionListGranteeInfoInterface(com.zimbra.soap.base.DistributionListGranteeInfoInterface) DistributionListInfo(com.zimbra.soap.account.type.DistributionListInfo) KeyValuePair(com.zimbra.soap.type.KeyValuePair) GetDistributionListRequest(com.zimbra.soap.account.message.GetDistributionListRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 63 with SoapTransport

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

the class TestAutoProvision method attributeCallbackAutoProvPollingInterval.

@Test
public void attributeCallbackAutoProvPollingInterval() throws Exception {
    Domain domain1 = createZimbraDomain(genDomainSegmentName("1"), null);
    domain1.setAutoProvMode(Provisioning.AutoProvMode.EAGER);
    Domain domain2 = createZimbraDomain(genDomainSegmentName("2"), null);
    domain2.setAutoProvMode(Provisioning.AutoProvMode.EAGER);
    Account admin = provUtil.createGlobalAdmin(genAcctNameLocalPart(), domain1);
    SoapTransport transport = authAdmin(admin.getName());
    /*
         * verify auto prov thread is not running at the beginning
         */
    verifyAutoProvTask(transport, Action.status, Status.idle);
    /*
         * schedule eager prov for domain1 and domain2 on server 
         */
    Server localServer = prov.getLocalServer();
    localServer.setAutoProvScheduledDomains(new String[] { domain1.getName(), domain2.getName() });
    /*
         * verify auto prov thread is now running, because at last one domain is scheduled
         */
    verifyAutoProvTask(transport, Action.status, Status.running);
    /*
         * set polling interval to 0, verify the auth prov thread is not running
         */
    // remember cur value and set it back after the test
    String curPollingInterval = localServer.getAutoProvPollingIntervalAsString();
    localServer.setAutoProvPollingInterval("0");
    verifyAutoProvTask(transport, Action.status, Status.idle);
    /*
         * done test, clean all data on the server
         */
    localServer.unsetAutoProvScheduledDomains();
    localServer.setAutoProvPollingInterval(curPollingInterval);
    Verify.verifyEquals(new HashSet<String>(), localServer.getAutoProvScheduledDomains());
    assertEquals(curPollingInterval, localServer.getAutoProvPollingIntervalAsString());
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) Domain(com.zimbra.cs.account.Domain) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 64 with SoapTransport

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

the class TestAutoProvision method revertAllToDefault.

// put everything back, in case the test did not run through previously
private static void revertAllToDefault() throws Exception {
    SoapTransport transport = authZimbraAdmin();
    modifyLocalconfigAndReload(transport, LC.autoprov_initial_sleep_ms, DEFAULT_AUTOPROV_INITIAL_SLEEP_MS);
    Server localServer = prov.getLocalServer();
    localServer.setAutoProvPollingInterval(DEFAULT_AUTOPROV_POLLING_INTERVAL);
    localServer.unsetAutoProvScheduledDomains();
}
Also used : Server(com.zimbra.cs.account.Server) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 65 with SoapTransport

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

the class TestAutoProvision method autoProvTaskControl.

@Test
public void autoProvTaskControl() throws Exception {
    Domain domain = createZimbraDomain(genDomainSegmentName(), null);
    Account admin = provUtil.createGlobalAdmin(genAcctNameLocalPart(), domain);
    SoapTransport transport = authAdmin(admin.getName());
    /*
         * verify auto prov thread is not running at the beginning
         */
    verifyAutoProvTask(transport, Action.status, Status.idle);
    /*
         * force start the auto prov thread, verify it is started
         */
    verifyAutoProvTask(transport, Action.start, Status.started);
    verifyAutoProvTask(transport, Action.status, Status.running);
    /*
         * force stop the auot prov thread, verify it is stopped
         */
    verifyAutoProvTask(transport, Action.stop, Status.stopped);
    verifyAutoProvTask(transport, Action.status, Status.idle);
}
Also used : Account(com.zimbra.cs.account.Account) Domain(com.zimbra.cs.account.Domain) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)85 Test (org.junit.Test)66 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)16 SoapFaultException (com.zimbra.common.soap.SoapFaultException)15 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 ArrayList (java.util.ArrayList)10 SoapProtocol (com.zimbra.common.soap.SoapProtocol)9 Bug (com.zimbra.qa.QA.Bug)9 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)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