use of com.zimbra.cs.account.Group 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);
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestDelegatedDL method init.
@BeforeClass
public static void init() throws Exception {
DOMAIN_NAME = baseDomainName();
ADMIN = TestUtil.getAddress("admin", DOMAIN_NAME);
USER_CREATOR = TestUtil.getAddress("creator", DOMAIN_NAME);
USER_OWNER = TestUtil.getAddress("owner", DOMAIN_NAME);
USER_NOT_OWNER = TestUtil.getAddress("not-owner", DOMAIN_NAME);
DL_NAME = TestUtil.getAddress("dl", DOMAIN_NAME);
provUtil = new SoapProvTestUtil();
prov = provUtil.getProv();
domain = provUtil.createDomain(DOMAIN_NAME, new HashMap<String, Object>());
Account admin = provUtil.createGlobalAdmin(ADMIN);
Account creator = provUtil.createAccount(USER_CREATOR, new HashMap<String, Object>());
Account owner = provUtil.createAccount(USER_OWNER, new HashMap<String, Object>());
Account notOwner = provUtil.createAccount(USER_NOT_OWNER, new HashMap<String, Object>());
prov.grantRight(TargetType.domain.getCode(), TargetBy.name, domain.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, creator.getName(), null, User.R_createDistList.getName(), null);
// create a DL for get/action tests
Multimap<String, String> attrs = ArrayListMultimap.create();
attrs.put(Provisioning.A_zimbraDistributionListSubscriptionPolicy, ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name());
Group group = createGroupAndAddOwner(DL_NAME, attrs, USER_OWNER);
}
use of com.zimbra.cs.account.Group 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);
}
use of com.zimbra.cs.account.Group 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);
}
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestDelegatedDL method InvalidOwnerEmail.
@Test
@Bug(bug = 72791)
public void InvalidOwnerEmail() throws Exception {
String GROUP_NAME = getAddress(genGroupNameLocalPart());
String errorCode = null;
try {
Group group = createGroupAndAddOwner(GROUP_NAME, "bogus@bogus.com");
} catch (ServiceException e) {
errorCode = e.getCode();
}
assertEquals(AccountServiceException.NO_SUCH_ACCOUNT, errorCode);
}
Aggregations