Search in sources :

Example 16 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class ImapTestBase method verifyFolderList.

public static void verifyFolderList(List<ListData> listResult, boolean mailOnly) {
    boolean hasContacts = false;
    boolean hasChats = false;
    boolean hasEmailedContacts = false;
    boolean hasTrash = false;
    boolean hasDrafts = false;
    boolean hasInbox = false;
    boolean hasJunk = false;
    boolean hasSent = false;
    for (ListData ld : listResult) {
        if ((ld.getMailbox().equalsIgnoreCase("Contacts"))) {
            hasContacts = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Chats"))) {
            hasChats = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Emailed Contacts"))) {
            hasEmailedContacts = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Trash"))) {
            hasTrash = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Drafts"))) {
            hasDrafts = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Inbox"))) {
            hasInbox = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Sent"))) {
            hasSent = true;
        } else if ((ld.getMailbox().equalsIgnoreCase("Junk"))) {
            hasJunk = true;
        }
    }
    if (mailOnly) {
        assertFalse("mail-only folderList contains Chats", hasChats);
        assertFalse("mail-only folderList contains Contacts", hasContacts);
        assertFalse("mail-only folderList contains Emailed Contacts", hasEmailedContacts);
    } else {
        assertTrue("folderList * does not contain Chats", hasChats);
        assertTrue("folderList * does not contain Contacts", hasContacts);
        assertTrue("folderList * does not contain Emailed Contacts", hasEmailedContacts);
    }
    assertTrue("folderList * does not contain Trash", hasTrash);
    assertTrue("folderList * does not contain Drafts ", hasDrafts);
    assertTrue("folderList * does not contain Inbox", hasInbox);
    assertTrue("folderList * does not contain Sent", hasSent);
    assertTrue("folderList * does not contain Junk", hasJunk);
}
Also used : ListData(com.zimbra.cs.mailclient.imap.ListData)

Example 17 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class SharedImapTests method listMountpointForAllApplicationsShare.

/**
 * Simulate how LIST handles the situation where a user has shared their whole mailbox with a sharee
 * and the sharee has used ZWC to add a shared folder for "All applications".
 *        "CreateMountpointRequest": [{
 *            "link": {
 *                "l": 1, "name": "owner's", "view": "unknown", "zid": "028fdbd8-d5de-483a-a545-11e421b8bd12", "rid": 1
 *            },
 *            "_jsns": "urn:zimbraMail"
 *        }], "_jsns": "urn:zimbra"
 */
@Test(timeout = 100000)
public void listMountpointForAllApplicationsShare() throws ServiceException, IOException {
    TestUtil.createAccount(SHAREE);
    ZMailbox shareeZmbox = TestUtil.getZMailbox(SHAREE);
    ZMailbox mbox = TestUtil.getZMailbox(USER);
    String sharedFolderName = String.format("%s-shared", testId);
    String remoteFolderPath = "/" + sharedFolderName;
    TestUtil.createFolder(mbox, remoteFolderPath);
    String mountpointName = String.format("%s's", USER, testId);
    ZGetInfoResult remoteInfo = mbox.getAccountInfo(true);
    String folderUserRoot = Integer.toString(Mailbox.ID_FOLDER_USER_ROOT);
    otherConnection = connectAndLogin(SHAREE);
    List<ListData> beforeListResult = otherConnection.list("", "*");
    assertNotNull("list result 'list \"\" \"*\"' should not be null (before share)", beforeListResult);
    mbox.modifyFolderGrant(folderUserRoot, GranteeType.all, null, "rwidx", null);
    shareeZmbox.createMountpoint(folderUserRoot, mountpointName, null, null, null, OwnerBy.BY_ID, remoteInfo.getId(), SharedItemBy.BY_ID, folderUserRoot, false);
    List<ListData> listResult;
    listResult = otherConnection.list("", "*");
    assertNotNull("list result 'list \"\" \"*\"' should not be null", listResult);
    boolean seenIt = false;
    for (ListData listEnt : listResult) {
        ZimbraLog.test.info("LIST result has entry '%s'", listEnt.getMailbox());
        if (mountpointName.equals(listEnt.getMailbox())) {
            seenIt = true;
            break;
        }
    }
    assertTrue(String.format("'%s' mountpoint not in result of 'list \"\" \"*\"'", mountpointName), seenIt);
    int extras = listResult.size() - beforeListResult.size();
    /* Extra entries should look something like these - i.e. a top level container and the sharer user's folders
         * under there.
         * LIST (\NoSelect \HasChildren) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's"
         * LIST (\HasNoChildren) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Chats"
         * LIST (\HasNoChildren) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Contacts"
         * LIST (\HasNoChildren \Drafts) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Drafts"
         * LIST (\HasNoChildren) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Emailed Contacts"
         * LIST (\HasNoChildren) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Inbox"
         * LIST (\NoInferiors \Junk) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Junk"
         * LIST (\HasNoChildren \Sent) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Sent"
         * LIST (\HasNoChildren) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/TestImapViaEmbeddedLocal-listMountpointForAllApplicationsShare-61-shared"
         * LIST (\HasNoChildren \Trash) "/" "testimapviaembeddedlocal-listmountpointforallapplicationsshare-61-user's/Trash"
         */
    assertTrue(String.format("'list \"\" \"*\"' response before share had %s entries, after %s entries (diff %s) expected >= 10 new", beforeListResult.size(), listResult.size(), extras), extras >= 10);
    otherConnection.logout();
    otherConnection = null;
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) ZGetInfoResult(com.zimbra.client.ZGetInfoResult) ListData(com.zimbra.cs.mailclient.imap.ListData) Test(org.junit.Test)

Example 18 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class TestImapUtil method parseFolders.

private List<ListData> parseFolders(String[] folders) throws IOException {
    List<ListData> lds = new ArrayList<ListData>();
    ImapInputStream is = getImapInputStream(folders);
    while (!is.isEOF()) {
        is.skipChar('*');
        is.skipChar(' ');
        is.readAtom();
        is.skipChar(' ');
        lds.add(ListData.read(is));
        is.skipCRLF();
    }
    return lds;
}
Also used : ArrayList(java.util.ArrayList) ImapInputStream(com.zimbra.cs.mailclient.imap.ImapInputStream) ListData(com.zimbra.cs.mailclient.imap.ListData)

Example 19 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class TestImapClient method testList.

@Test
public void testList() throws Exception {
    login();
    List<ListData> lds = connection.list("", "*");
    for (ListData ld : lds) {
        assertEquals('/', ld.getDelimiter());
        assertNotNull(ld.getMailbox());
        assertTrue(ld.getFlags().size() > 0);
    }
}
Also used : ListData(com.zimbra.cs.mailclient.imap.ListData) Test(org.junit.Test)

Aggregations

ListData (com.zimbra.cs.mailclient.imap.ListData)19 Test (org.junit.Test)13 ZMailbox (com.zimbra.client.ZMailbox)6 ZFolder (com.zimbra.client.ZFolder)2 ServiceException (com.zimbra.common.service.ServiceException)2 CommandFailedException (com.zimbra.cs.mailclient.CommandFailedException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ZGetInfoResult (com.zimbra.client.ZGetInfoResult)1 ZSearchFolder (com.zimbra.client.ZSearchFolder)1 RemoteServiceException (com.zimbra.common.service.RemoteServiceException)1 AuthTokenException (com.zimbra.cs.account.AuthTokenException)1 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)1 Envelope (com.zimbra.cs.mailclient.imap.Envelope)1 ImapInputStream (com.zimbra.cs.mailclient.imap.ImapInputStream)1 MessageData (com.zimbra.cs.mailclient.imap.MessageData)1 AuthProviderException (com.zimbra.cs.service.AuthProviderException)1 Method (java.lang.reflect.Method)1 TimeoutException (java.util.concurrent.TimeoutException)1 MessagingException (javax.mail.MessagingException)1