use of com.zimbra.soap.account.type.DistributionListInfo in project zm-mailbox by Zimbra.
the class TestDelegatedDL method distributionListActionAddRemoveOwners.
@Test
public void distributionListActionAddRemoveOwners() throws Exception {
String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
Group group = createGroupAndAddOwner(GROUP_NAME);
Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
SoapTransport transport = authUser(USER_OWNER);
//
// addOwners
//
DistributionListAction action = new DistributionListAction(Operation.addOwners);
DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, USER_OWNER));
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
DistributionListActionResponse resp = invokeJaxb(transport, req);
//
// verify owners are added
//
GetDistributionListRequest getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
GetDistributionListResponse getDLResp = invokeJaxb(transport, getDLReq);
DistributionListInfo dlInfo = getDLResp.getDl();
List<? extends DistributionListGranteeInfoInterface> owners = dlInfo.getOwners();
Set<String> ownerNames = Sets.newHashSet();
for (DistributionListGranteeInfoInterface owner : owners) {
if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
ownerNames.add(owner.getName());
}
}
assertEquals(3, owners.size());
Verify.verifyEquals(Sets.newHashSet(USER_OWNER, owner1.getName(), owner2.getName()), ownerNames);
//
// removeOwners
//
action = new DistributionListAction(Operation.removeOwners);
req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
resp = invokeJaxb(transport, req);
//
// verify owners are removed
//
getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
getDLResp = invokeJaxb(transport, getDLReq);
dlInfo = getDLResp.getDl();
owners = dlInfo.getOwners();
ownerNames = Sets.newHashSet();
for (DistributionListGranteeInfoInterface owner : owners) {
if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
ownerNames.add(owner.getName());
}
}
assertEquals(1, owners.size());
Verify.verifyEquals(Sets.newHashSet(USER_OWNER), ownerNames);
}
use of com.zimbra.soap.account.type.DistributionListInfo in project zm-mailbox by Zimbra.
the class TestDelegatedDL method getDistributionListByGlobalAdmin.
/*
* verify and request is allowed, but isOwner is false
*/
@Test
public void getDistributionListByGlobalAdmin() throws Exception {
SoapTransport transport = authAdmin(ADMIN);
GetDistributionListRequest req = new GetDistributionListRequest(DistributionListSelector.fromName(DL_NAME), Boolean.TRUE);
GetDistributionListResponse resp = invokeJaxb(transport, req);
DistributionListInfo dlInfo = resp.getDl();
assertFalse(dlInfo.isOwner());
String dlId = dlInfo.getId();
Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
assertNotNull(group);
assertEquals(group.getId(), dlId);
}
use of com.zimbra.soap.account.type.DistributionListInfo 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);
}
}
Aggregations