Search in sources :

Example 1 with CreateDistributionListRequest

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

the class TestDelegatedDL method createDelegatedGroup.

private static Group createDelegatedGroup(SoapTransport transport, String groupName, List<KeyValuePair> attrs) throws Exception {
    Group group = prov.getGroup(Key.DistributionListBy.name, groupName);
    assertNull(group);
    CreateDistributionListRequest req = new CreateDistributionListRequest(groupName, attrs, DYNAMIC);
    CreateDistributionListResponse resp = invokeJaxb(transport, req);
    group = prov.getGroup(Key.DistributionListBy.name, groupName);
    assertNotNull(group);
    assertEquals(groupName, group.getName());
    assertNotNull(group.getAttr(Provisioning.A_zimbraMailHost));
    return group;
}
Also used : Group(com.zimbra.cs.account.Group) CreateDistributionListRequest(com.zimbra.soap.account.message.CreateDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.account.message.CreateDistributionListResponse)

Example 2 with CreateDistributionListRequest

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

the class TestDelegatedDL method createDistributionListPermDenied.

@Test
public void createDistributionListPermDenied() throws Exception {
    String dlName = getAddress(genGroupNameLocalPart());
    SoapTransport transport = authUser(USER_OWNER);
    CreateDistributionListRequest req = new CreateDistributionListRequest(dlName, null, DYNAMIC);
    boolean caughtPermDenied = false;
    try {
        CreateDistributionListResponse resp = invokeJaxb(transport, req);
    } catch (SoapFaultException e) {
        String code = e.getCode();
        if (ServiceException.PERM_DENIED.equals(code)) {
            caughtPermDenied = true;
        }
    }
    assertTrue(caughtPermDenied);
}
Also used : CreateDistributionListRequest(com.zimbra.soap.account.message.CreateDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.account.message.CreateDistributionListResponse) SoapTransport(com.zimbra.common.soap.SoapTransport) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 3 with CreateDistributionListRequest

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

the class TestDelegatedDL method createDistributionList.

@Test
public void createDistributionList() throws Exception {
    String dlName = getAddress(genGroupNameLocalPart());
    SoapTransport transport = authUser(USER_CREATOR);
    CreateDistributionListRequest req = new CreateDistributionListRequest(dlName, null, DYNAMIC);
    List<KeyValuePair> attrsCreate = Lists.newArrayList(new KeyValuePair(Provisioning.A_zimbraDistributionListSubscriptionPolicy, ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name()));
    req.setKeyValuePairs(attrsCreate);
    CreateDistributionListResponse resp = invokeJaxb(transport, req);
    DLInfo dlInfo = resp.getDl();
    String dlId = dlInfo.getId();
    Group group = prov.getGroup(Key.DistributionListBy.name, dlName);
    assertNotNull(group);
    assertEquals(group.getId(), dlId);
    boolean seenExpectedMail = false;
    boolean seenExpectedSubsPolicy = 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);
            seenExpectedMail = true;
        }
        if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(name)) {
            assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
            seenExpectedSubsPolicy = true;
        }
    }
    assertTrue(seenExpectedMail);
    assertTrue(seenExpectedSubsPolicy);
}
Also used : Group(com.zimbra.cs.account.Group) CreateDistributionListRequest(com.zimbra.soap.account.message.CreateDistributionListRequest) KeyValuePair(com.zimbra.soap.type.KeyValuePair) CreateDistributionListResponse(com.zimbra.soap.account.message.CreateDistributionListResponse) DLInfo(com.zimbra.soap.account.type.DLInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 4 with CreateDistributionListRequest

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

the class TestDelegatedDL method createGroupAndAddOwner.

private static Group createGroupAndAddOwner(String groupName, Multimap<String, String> attrs, String ownerName) throws Exception {
    Group group = prov.getGroup(Key.DistributionListBy.name, groupName);
    assertNull(group);
    SoapTransport transport = authUser(USER_CREATOR);
    CreateDistributionListRequest req = new CreateDistributionListRequest(groupName, KeyValuePair.fromMultimap(attrs), DYNAMIC);
    CreateDistributionListResponse resp = invokeJaxb(transport, req);
    group = prov.getGroup(Key.DistributionListBy.name, groupName);
    assertNotNull(group);
    assertEquals(groupName, group.getName());
    assertNotNull(group.getAttr(Provisioning.A_zimbraMailHost));
    /*
         * USER_CREATOR is automatically an owner now.
         */
    // add ownerName as an owner
    addOwner(transport, groupName, ownerName);
    // remove USER_CREATOR from the owner list
    removeOwner(transport, groupName, USER_CREATOR);
    return group;
}
Also used : Group(com.zimbra.cs.account.Group) CreateDistributionListRequest(com.zimbra.soap.account.message.CreateDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.account.message.CreateDistributionListResponse) SoapTransport(com.zimbra.common.soap.SoapTransport)

Aggregations

CreateDistributionListRequest (com.zimbra.soap.account.message.CreateDistributionListRequest)4 CreateDistributionListResponse (com.zimbra.soap.account.message.CreateDistributionListResponse)4 SoapTransport (com.zimbra.common.soap.SoapTransport)3 Group (com.zimbra.cs.account.Group)3 Test (org.junit.Test)2 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 DLInfo (com.zimbra.soap.account.type.DLInfo)1 KeyValuePair (com.zimbra.soap.type.KeyValuePair)1