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;
}
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);
}
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);
}
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;
}
Aggregations