Search in sources :

Example 61 with ZFolder

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());
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) ZFolder(com.zimbra.client.ZFolder)

Example 62 with ZFolder

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());
}
Also used : ZFolder(com.zimbra.client.ZFolder) Test(org.junit.Test)

Example 63 with ZFolder

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()));
}
Also used : Account(com.zimbra.cs.account.Account) FolderActionResponse(com.zimbra.soap.mail.message.FolderActionResponse) SendShareNotificationResponse(com.zimbra.soap.mail.message.SendShareNotificationResponse) ActionGrantSelector(com.zimbra.soap.mail.type.ActionGrantSelector) FolderActionSelector(com.zimbra.soap.mail.type.FolderActionSelector) ZMailbox(com.zimbra.client.ZMailbox) ShareNotificationInfo(com.zimbra.soap.mail.type.ShareNotificationInfo) FolderActionRequest(com.zimbra.soap.mail.message.FolderActionRequest) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) ZFolder(com.zimbra.client.ZFolder) SendShareNotificationRequest(com.zimbra.soap.mail.message.SendShareNotificationRequest)

Example 64 with ZFolder

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()));
}
Also used : Account(com.zimbra.cs.account.Account) FolderActionResponse(com.zimbra.soap.mail.message.FolderActionResponse) SendShareNotificationResponse(com.zimbra.soap.mail.message.SendShareNotificationResponse) ActionGrantSelector(com.zimbra.soap.mail.type.ActionGrantSelector) FolderActionSelector(com.zimbra.soap.mail.type.FolderActionSelector) ZMailbox(com.zimbra.client.ZMailbox) ShareNotificationInfo(com.zimbra.soap.mail.type.ShareNotificationInfo) FolderActionRequest(com.zimbra.soap.mail.message.FolderActionRequest) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) ZFolder(com.zimbra.client.ZFolder) SendShareNotificationRequest(com.zimbra.soap.mail.message.SendShareNotificationRequest)

Example 65 with ZFolder

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);
}
Also used : ZAce(com.zimbra.client.ZAce) Account(com.zimbra.cs.account.Account) ZMailbox(com.zimbra.client.ZMailbox) ArrayList(java.util.ArrayList) ZFolder(com.zimbra.client.ZFolder) Bug(com.zimbra.qa.QA.Bug)

Aggregations

ZFolder (com.zimbra.client.ZFolder)84 ZMailbox (com.zimbra.client.ZMailbox)54 Folder (com.zimbra.cs.mailbox.Folder)21 Test (org.junit.Test)21 ServiceException (com.zimbra.common.service.ServiceException)19 Account (com.zimbra.cs.account.Account)19 Mailbox (com.zimbra.cs.mailbox.Mailbox)17 Mountpoint (com.zimbra.cs.mailbox.Mountpoint)17 SearchFolder (com.zimbra.cs.mailbox.SearchFolder)13 ItemId (com.zimbra.cs.service.util.ItemId)13 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)12 ZMessage (com.zimbra.client.ZMessage)10 ZMountpoint (com.zimbra.client.ZMountpoint)9 AccountServiceException (com.zimbra.cs.account.AccountServiceException)9 ZAuthToken (com.zimbra.common.auth.ZAuthToken)7 ArrayList (java.util.ArrayList)7 ZDataSource (com.zimbra.client.ZDataSource)6 ZSearchFolder (com.zimbra.client.ZSearchFolder)6 Provisioning (com.zimbra.cs.account.Provisioning)6 AuthToken (com.zimbra.cs.account.AuthToken)5