Search in sources :

Example 56 with SoapTransport

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

the class TestDelegatedDL method hideInGal.

@Test
@Bug(bug = 66234)
public void hideInGal() throws Exception {
    // setup GAL sync account
    GalTestUtil.enableGalSyncAccount(prov, domain.getName());
    String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
    Multimap<String, String> attrs = ArrayListMultimap.create();
    attrs.put(Provisioning.A_zimbraHideInGal, ProvisioningConstants.TRUE);
    // create an owner account
    Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
    Group group = createGroupAndAddOwner(GROUP_NAME, attrs, ownerAcct.getName());
    // create member accounts and add it to the group
    Account memberAcct1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
    Account memberAcct2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
    Account memberAcct3 = provUtil.createAccount(genAcctNameLocalPart("member3"), domain);
    prov.addGroupMembers(group, new String[] { memberAcct3.getName(), memberAcct2.getName(), memberAcct1.getName() });
    // create a non-member account
    Account nonMemberAcct = provUtil.createAccount(genAcctNameLocalPart("non-member"), domain);
    /*
         * Owners should be able to see members even when the list is hideInGal
         */
    // auth as the owner
    SoapTransport transport = authUser(ownerAcct.getName());
    GetDistributionListMembersRequest req = new GetDistributionListMembersRequest(null, null, group.getName());
    GetDistributionListMembersResponse resp = invokeJaxb(transport, req);
    List<String> members = resp.getDlMembers();
    //make sure members are returned sorted
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
    // add another member, verify cache is updated
    Account memberAcct4 = provUtil.createAccount(genAcctNameLocalPart("member4"), domain);
    prov.addGroupMembers(group, new String[] { memberAcct4.getName() });
    resp = invokeJaxb(transport, req);
    members = resp.getDlMembers();
    Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName()), members);
    String errorCode = null;
    /*
         * non owner cannot see members when the list is hideInGal
         */
    transport = authUser(memberAcct1.getName());
    errorCode = null;
    try {
        invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
    /*
         * non owner cannot see members when the list is hideInGal
         */
    transport = authUser(nonMemberAcct.getName());
    errorCode = null;
    try {
        invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
    GalTestUtil.disableGalSyncAccount(prov, domain.getName());
    provUtil.deleteAccount(ownerAcct);
    provUtil.deleteAccount(memberAcct1);
    provUtil.deleteAccount(memberAcct2);
    provUtil.deleteAccount(memberAcct3);
    provUtil.deleteAccount(memberAcct4);
    provUtil.deleteAccount(nonMemberAcct);
    provUtil.deleteGroup(group);
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) GetDistributionListMembersResponse(com.zimbra.soap.account.message.GetDistributionListMembersResponse) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) GetDistributionListMembersRequest(com.zimbra.soap.account.message.GetDistributionListMembersRequest) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 57 with SoapTransport

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

the class TestDelegatedDL method distributionListActionDelete.

@Test
public void distributionListActionDelete() throws Exception {
    // create a group for the delete test
    String NAME = getAddress(genGroupNameLocalPart());
    Group group = createGroupAndAddOwner(NAME);
    SoapTransport transport = authUser(USER_OWNER);
    DistributionListAction action = new DistributionListAction(Operation.delete);
    DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(NAME), action);
    DistributionListActionResponse resp;
    String errorCode = null;
    try {
        // only people with create right and owner right can delete
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(ServiceException.PERM_DENIED, errorCode);
    /*
         * auth as creator and try again, should still fail
         */
    transport = authUser(USER_CREATOR);
    errorCode = null;
    try {
        resp = invokeJaxb(transport, req);
    } catch (ServiceException e) {
        errorCode = e.getCode();
    }
    assertEquals(ServiceException.PERM_DENIED, errorCode);
    // make the creator an owner
    transport = authUser(USER_OWNER);
    addOwner(transport, group.getName(), USER_CREATOR);
    // now try delete as the creator (also an owner now), should succeed
    transport = authUser(USER_CREATOR);
    resp = invokeJaxb(transport, req);
    group = prov.getGroup(Key.DistributionListBy.name, NAME);
    assertNull(null);
}
Also used : Group(com.zimbra.cs.account.Group) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) DistributionListActionResponse(com.zimbra.soap.account.message.DistributionListActionResponse) DistributionListAction(com.zimbra.soap.account.type.DistributionListAction) SoapTransport(com.zimbra.common.soap.SoapTransport) DistributionListActionRequest(com.zimbra.soap.account.message.DistributionListActionRequest) Test(org.junit.Test)

Example 58 with SoapTransport

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

the class TestCsrfRequest method getCreateSigWithAuthAndCsrfDisabled.

@Test
public void getCreateSigWithAuthAndCsrfDisabled() 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/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");
        assertNotNull(sigt);
    } catch (SoapFaultException e) {
        e.printStackTrace();
        assertNull(e);
    }
}
Also used : Account(com.zimbra.cs.account.Account) CreateSignatureRequest(com.zimbra.soap.account.message.CreateSignatureRequest) 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 59 with SoapTransport

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

the class TestCsrfRequest method getCreateSigWithAuthAndCsrfEnabledNoCsrfToken.

@Test
public void getCreateSigWithAuthAndCsrfEnabledNoCsrfToken() throws Exception {
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
    boolean csrfEnabled = Boolean.TRUE;
    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/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);
    } 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) 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 60 with SoapTransport

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

the class TestCsrfRequest method getCreateSigWithAuthAndCsrfEnabledAndCsrfToken.

@Test
public void getCreateSigWithAuthAndCsrfEnabledAndCsrfToken() throws Exception {
    Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
    boolean csrfEnabled = Boolean.TRUE;
    SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.TRUE);
    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");
        assertNotNull(sigt);
    } catch (SoapFaultException e) {
        assertNull(e);
    }
}
Also used : Account(com.zimbra.cs.account.Account) CreateSignatureRequest(com.zimbra.soap.account.message.CreateSignatureRequest) 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)

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