use of com.zimbra.client.ZFolder in project zm-mailbox by Zimbra.
the class TestFilter method testMountpoint.
/**
* Tests filing into a mountpoint folder.
*/
public void testMountpoint() throws Exception {
// Send message.
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String address = TestUtil.getAddress(USER_NAME);
String subject = NAME_PREFIX + " mountpointRoot1";
TestUtil.addMessageLmtp(subject, address, address);
// Confirm that it gets filed into the mountpoint folder and not in inbox.
TestUtil.waitForMessage(mbox, "in:\"/" + MOUNTPOINT_FOLDER_NAME + "\" subject:\"" + subject + "\"");
assertEquals(0, TestUtil.search(mbox, "in:inbox subject:\"" + subject + "\"").size());
// Delete the remote folder.
ZMailbox remote = TestUtil.getZMailbox(REMOTE_USER_NAME);
ZFolder remoteFolder = remote.getFolderByPath("/" + MOUNTPOINT_FOLDER_NAME);
remote.deleteFolder(remoteFolder.getId());
// Send another message, confirm that it gets filed into inbox and not in the mountpoint folder.
subject = NAME_PREFIX + " mountpointRoot2";
TestUtil.addMessageLmtp(subject, address, address);
TestUtil.waitForMessage(mbox, "in:inbox subject:\"" + subject + "\"");
assertEquals(0, TestUtil.search(mbox, "in:\"/" + MOUNTPOINT_FOLDER_NAME + "\" subject:\"" + subject + "\"").size());
}
use of com.zimbra.client.ZFolder in project zm-mailbox by Zimbra.
the class TestDraftCount method testCustomFolderCount.
@Test
public void testCustomFolderCount() throws Exception {
String folderName = "Test Custom Folder";
ZFolder folder = mbox.createFolder("1", folderName, ZFolder.View.message, null, null, null);
for (int i = 0; i < numMsgs; i++) {
TestUtil.addMessage(mbox, "test content " + i, folder.getId());
}
checkMessageCount("in:\"" + folderName + "\"", numMsgs);
mbox.deleteFolder(folder.getId());
}
use of com.zimbra.client.ZFolder in project zm-mailbox by Zimbra.
the class TestShareNotifications method testMultipleCalendarShareNotifications.
public void testMultipleCalendarShareNotifications() throws Exception {
Account senderAccount = TestUtil.createAccount(SENDER_NAME);
Account recipientAccount = TestUtil.createAccount(RECIPIENT_NAME);
ZMailbox mbox = TestUtil.getZMailbox(SENDER_NAME);
// check that there are no share notifications in the recipient's mailbox
ZMailbox recipientMbox = TestUtil.getZMailbox(RECIPIENT_NAME);
List<ShareNotificationInfo> shares = waitForShareNotifications(recipientMbox, 0, 100);
assertEquals("Recipient should have exactly 0 share notification", 0, shares.size());
// create and share the first calendar
ZFolder newCal = TestUtil.createFolder(mbox, CAL_NAME1, ZFolder.View.appointment);
String calendarId = newCal.getId();
FolderActionSelector action = new FolderActionSelector(calendarId, "grant");
ActionGrantSelector grant = new ActionGrantSelector("r", "usr");
grant.setDisplayName(recipientAccount.getName());
grant.setPassword("");
action.setGrant(grant);
FolderActionRequest folderActionReq = new FolderActionRequest(action);
FolderActionResponse folderActionResp = mbox.invokeJaxb(folderActionReq);
assertNotNull("FolderActionResponse is null", folderActionResp);
SendShareNotificationRequest shareNotificationReq = new SendShareNotificationRequest();
shareNotificationReq.setItem(new com.zimbra.soap.type.Id(calendarId));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
SendShareNotificationResponse resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
// create and share the second calendar
ZFolder newCal2 = TestUtil.createFolder(mbox, CAL_NAME2, ZFolder.View.appointment);
String calendarId2 = newCal2.getId();
action = new FolderActionSelector(calendarId2, "grant");
grant = new ActionGrantSelector("r", "usr");
grant.setDisplayName(recipientAccount.getName());
grant.setPassword("");
action.setGrant(grant);
folderActionReq = new FolderActionRequest(action);
folderActionResp = mbox.invokeJaxb(folderActionReq);
assertNotNull("FolderActionResponse is null", folderActionResp);
shareNotificationReq = new SendShareNotificationRequest();
shareNotificationReq.setItem(new com.zimbra.soap.type.Id(calendarId2));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
shares = waitForShareNotifications(recipientMbox, 2, 1000);
assertEquals("should have exactly two share notification", 2, shares.size());
assertNotNull("share grantor is null", shares.get(0).getGrantor());
assertTrue("share grantor is not " + senderAccount.getMail(), senderAccount.getMail().equalsIgnoreCase(shares.get(0).getGrantor().getEmail()));
}
use of com.zimbra.client.ZFolder in project zm-mailbox by Zimbra.
the class TestShareNotifications method testCalendarShareNotification.
public void testCalendarShareNotification() throws Exception {
Account senderAccount = TestUtil.createAccount(SENDER_NAME);
Account recipientAccount = TestUtil.createAccount(RECIPIENT_NAME);
ZMailbox mbox = TestUtil.getZMailbox(SENDER_NAME);
// check that there are no share notifications in the recipient's mailbox
ZMailbox recipientMbox = TestUtil.getZMailbox(RECIPIENT_NAME);
List<ShareNotificationInfo> shares = waitForShareNotifications(recipientMbox, 0, 100);
assertEquals("Recipient should have exactly 0 share notification", 0, shares.size());
ZFolder newCal = TestUtil.createFolder(mbox, CAL_NAME1, ZFolder.View.appointment);
String calendarId = newCal.getId();
FolderActionSelector action = new FolderActionSelector(calendarId, "grant");
ActionGrantSelector grant = new ActionGrantSelector("r", "usr");
grant.setDisplayName(recipientAccount.getName());
grant.setPassword("");
action.setGrant(grant);
FolderActionRequest folderActionReq = new FolderActionRequest(action);
FolderActionResponse folderActionResp = mbox.invokeJaxb(folderActionReq);
assertNotNull("FolderActionResponse is null", folderActionResp);
SendShareNotificationRequest shareNotificationReq = new SendShareNotificationRequest();
shareNotificationReq.setItem(new com.zimbra.soap.type.Id(calendarId));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
SendShareNotificationResponse resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
shares = waitForShareNotifications(recipientMbox, 1, 1000);
assertTrue("should have exactly one share notification", shares.size() == 1);
assertNotNull("share grantor is null", shares.get(0).getGrantor());
assertTrue("share grantor is not " + senderAccount.getMail(), senderAccount.getMail().equalsIgnoreCase(shares.get(0).getGrantor().getEmail()));
}
use of com.zimbra.client.ZFolder in project zm-mailbox by Zimbra.
the class TestACLUserRights method testFallbackToFolderRight.
@Test
@Bug(bug = 42146)
public void testFallbackToFolderRight() throws Exception {
// grantees
Account allowed = createUserAccount("allowed");
Account denied = createUserAccount("denied");
Account noAclButHasFolderGrant = createUserAccount("noAclButHasFolderGrant");
Account noAclAndNoFolderGrant = createUserAccount("noAclAndNoFolderGrant");
// owner
Account owner = createUserAccount("owner");
ZMailbox ownerMbox = TestUtil.getZMailbox(owner.getName());
// grant account right
ZAce aceAllow = new ZAce(ZAce.GranteeType.usr, allowed.getId(), allowed.getName(), "invite", false, null);
ownerMbox.grantRight(aceAllow);
ZAce aceDeny = new ZAce(ZAce.GranteeType.usr, denied.getId(), denied.getName(), "invite", true, null);
ownerMbox.grantRight(aceDeny);
// grant folder right
String folderPath = "/Calendar";
short rights = ACL.RIGHT_READ | ACL.RIGHT_WRITE | ACL.RIGHT_INSERT | ACL.RIGHT_DELETE;
String rightsStr = ACL.rightsToString(rights);
ZFolder folder = ownerMbox.getFolder(folderPath);
ownerMbox.modifyFolderGrant(folder.getId(), ZGrant.GranteeType.usr, denied.getName(), rightsStr, null);
ownerMbox.modifyFolderGrant(folder.getId(), ZGrant.GranteeType.usr, noAclButHasFolderGrant.getName(), rightsStr, null);
// check permission
List<String> rightsToCheck = new ArrayList<String>();
rightsToCheck.add("invite");
boolean result;
result = TestUtil.getZMailbox(allowed.getName()).checkRights(owner.getName(), rightsToCheck);
assertTrue(result);
result = TestUtil.getZMailbox(denied.getName()).checkRights(owner.getName(), rightsToCheck);
assertTrue(result);
result = TestUtil.getZMailbox(noAclButHasFolderGrant.getName()).checkRights(owner.getName(), rightsToCheck);
assertTrue(result);
result = TestUtil.getZMailbox(noAclAndNoFolderGrant.getName()).checkRights(owner.getName(), rightsToCheck);
assertFalse(result);
}
Aggregations