use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDelegatedDL method distributionListActionSetBadOwners.
@Test
@Bug(bug = 72791)
public void distributionListActionSetBadOwners() throws Exception {
String GROUP_NAME = getAddress(genGroupNameLocalPart());
Group group = createGroupAndAddOwner(GROUP_NAME);
Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
Account owner3 = provUtil.createAccount(genAcctNameLocalPart("3"), domain);
SoapTransport transport = authUser(USER_OWNER);
//
// setOwners: some good owners an a bogus owner (not a user)
//
DistributionListAction action = new DistributionListAction(Operation.setOwners);
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()));
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner3.getName()));
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, "bogus@bogus.com"));
String errorCode = null;
try {
DistributionListActionResponse resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
errorCode = e.getCode();
}
assertEquals(AccountServiceException.NO_SUCH_ACCOUNT, errorCode);
//
// verify owners are NOT replaced
//
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(1, owners.size());
Verify.verifyEquals(Sets.newHashSet(USER_OWNER), ownerNames);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDelegatedDL method distributionListActionManipulateOwnerRight.
/*
* verify owner right can never be altered directly, all modification on
* owners must go through addOwners/remvoeOwners/setOwners operations
*/
@Test
public void distributionListActionManipulateOwnerRight() throws Exception {
String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
Group group = createGroupAndAddOwner(GROUP_NAME);
String right = Group.GroupOwner.GROUP_OWNER_RIGHT.getName();
Account grantee = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
SoapTransport transport = authUser(USER_OWNER);
//
// grantRights
//
DistributionListAction action = new DistributionListAction(Operation.grantRights);
DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
DistributionListRightSpec dlRight = new DistributionListRightSpec(right);
dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
action.addRight(dlRight);
DistributionListActionResponse resp;
boolean caughtException = false;
try {
resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
caughtException = true;
}
}
assertTrue(caughtException);
//
// revokeRights
//
action = new DistributionListAction(Operation.revokeRights);
req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
dlRight = new DistributionListRightSpec(right);
dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
action.addRight(dlRight);
caughtException = false;
try {
resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
caughtException = true;
}
}
assertTrue(caughtException);
//
// setRights
//
action = new DistributionListAction(Operation.setRights);
req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
dlRight = new DistributionListRightSpec(right);
dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
action.addRight(dlRight);
caughtException = false;
try {
resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
caughtException = true;
}
}
assertTrue(caughtException);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDelegatedDL method distributionListActionSetOwners.
@Test
public void distributionListActionSetOwners() 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);
Account owner3 = provUtil.createAccount(genAcctNameLocalPart("3"), domain);
SoapTransport transport = authUser(USER_OWNER);
//
// setOwners
//
DistributionListAction action = new DistributionListAction(Operation.setOwners);
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()));
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, owner3.getName()));
DistributionListActionResponse resp = invokeJaxb(transport, req);
//
// verify owners are replaced
//
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(4, owners.size());
Verify.verifyEquals(Sets.newHashSet(USER_OWNER, owner1.getName(), owner2.getName(), owner3.getName()), ownerNames);
/*
* test invalid grantee type for owner
*/
action = new DistributionListAction(Operation.setOwners);
req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, "user@external.com"));
String errCode = null;
try {
resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
errCode = e.getCode();
}
assertEquals(ServiceException.INVALID_REQUEST, errCode);
// remove all owners
action = new DistributionListAction(Operation.setOwners);
req = new DistributionListActionRequest(DistributionListSelector.fromName(GROUP_NAME), action);
resp = invokeJaxb(transport, req);
getDLReq = new GetDistributionListRequest(DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
getDLResp = invokeJaxb(transport, getDLReq);
dlInfo = getDLResp.getDl();
owners = dlInfo.getOwners();
assertEquals(0, owners.size());
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestExpandGroupInfo method getMsg.
@Test
public void getMsg() throws Exception {
String SUBJECT = getTestName();
String msgId = createAppt(acct, group.getName(), SUBJECT, "blah");
SoapTransport transport = authUser(acct.getName());
MsgSpec msgSpec = new MsgSpec(msgId);
msgSpec.setNeedCanExpand(Boolean.TRUE);
GetMsgRequest req = new GetMsgRequest(msgSpec);
GetMsgResponse resp = invokeJaxb(transport, req);
MsgWithGroupInfo msg = resp.getMsg();
InviteWithGroupInfo invite = msg.getInvite();
List<InviteComponentWithGroupInfo> invComps = invite.getInviteComponents();
for (InviteComponentWithGroupInfo invComp : invComps) {
List<CalendarAttendeeWithGroupInfo> attendees = invComp.getAttendees();
for (CalendarAttendeeWithGroupInfo attendee : attendees) {
Boolean isGroup = attendee.getGroup();
Boolean canExpandGroupMembers = attendee.getCanExpandGroupMembers();
assertTrue(isGroup);
assertTrue(canExpandGroupMembers);
}
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestExpandGroupInfo method search.
@Test
public void search() throws Exception {
// send a to acct, recipient is a group
String SUBJECT = getTestName();
sendMsg(acct, group.getName(), SUBJECT, "blah");
SoapTransport transport = authUser(acct.getName());
SearchRequest searchReq = new SearchRequest();
searchReq.setSearchTypes(MailItem.Type.MESSAGE.toString());
searchReq.setQuery(String.format("in:inbox and subject:%s", SUBJECT));
searchReq.setFetch(SearchParams.ExpandResults.ALL.toString());
SearchResponse searchResp = invokeJaxb(transport, searchReq);
List<SearchHit> searchHits = searchResp.getSearchHits();
assertEquals(1, searchHits.size());
verifyGroupInfo((MessageHitInfo) searchHits.get(0), null, null);
/*
* search again with needExp
*/
searchReq.setNeedCanExpand(Boolean.TRUE);
searchResp = invokeJaxb(transport, searchReq);
searchHits = searchResp.getSearchHits();
assertEquals(1, searchHits.size());
verifyGroupInfo((MessageHitInfo) searchHits.get(0), Boolean.TRUE, Boolean.TRUE);
}
Aggregations