void annotatemore() { QFETCH(QList<QByteArray>, scenario); QFETCH(QString, mailbox); QFETCH(MAP, annotations); QFETCH(bool, legacyMode); FakeServer fakeServer; fakeServer.setScenario(scenario); fakeServer.startAndWait(); KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989); KIMAP::SetMetaDataJob *setMetadataJob = new KIMAP::SetMetaDataJob(&session); setMetadataJob->setServerCapability(KIMAP::MetaDataJobBase::Annotatemore); setMetadataJob->setMailBox(mailbox); foreach (const QByteArray &entry, annotations.keys()) { if (legacyMode) { setMetadataJob->setEntry(entry); setMetadataJob->addMetaData("value.shared", annotations[entry]); } else { setMetadataJob->addMetaData(QByteArray("/shared") + entry, annotations[entry]); } } QVERIFY(setMetadataJob->exec()); fakeServer.quit(); }
void testGetQuotaRoot() { QFETCH( QString, mailbox ); QFETCH( QList<QByteArray>, roots ); QFETCH( QList<QByteArray>, resources ); QFETCH( QList<qint64>, usages ); QFETCH( QList<qint64>, limits ); QFETCH( QList<QByteArray>, scenario ); FakeServer fakeServer; fakeServer.setScenario( scenario ); fakeServer.startAndWait(); KIMAP::Session session( "127.0.0.1", 5989 ); KIMAP::GetQuotaRootJob *job = new KIMAP::GetQuotaRootJob( &session ); job->setMailBox( mailbox ); bool result = job->exec(); QEXPECT_FAIL( "bad" , "Expected failure on BAD response", Continue ); QEXPECT_FAIL( "no" , "Expected failure on NO response", Continue ); QVERIFY( result ); QEXPECT_FAIL( "rootname missmatch" , "Expected failure on rootname missmatch in QUOTAROOT and QUOTA response", Abort ); QCOMPARE( job->roots(), roots ); for ( int rootIdx = 0; rootIdx < roots.size(); rootIdx++ ) { const QByteArray &root = roots[rootIdx]; for ( int i = 0; i < resources.size(); i++ ) { int idx = i + rootIdx * roots.size(); QByteArray resource = resources[i]; QCOMPARE( job->limit( root, resource ), limits[idx] ); QCOMPARE( job->usage( root, resource ), usages[idx] ); } } fakeServer.quit(); }
void testCapabilities() { QFETCH( QList<QByteArray>, scenario ); QFETCH( QStringList, capabilities ); FakeServer fakeServer; fakeServer.setScenario( scenario ); fakeServer.startAndWait(); KIMAP::Session session( "127.0.0.1", 5989 ); KIMAP::CapabilitiesJob *job = new KIMAP::CapabilitiesJob( &session ); bool result = job->exec(); QEXPECT_FAIL( "bad" , "Expected failure on BAD response", Continue ); QVERIFY( result ); if ( result ) { QCOMPARE( job->capabilities(), capabilities ); } fakeServer.quit(); }
void testSubscribe() { QFETCH(QString, mailbox); QFETCH(QList<QByteArray>, scenario); FakeServer fakeServer; fakeServer.setScenario(scenario); fakeServer.startAndWait(); KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989); KIMAP::SubscribeJob *job = new KIMAP::SubscribeJob(&session); job->setMailBox(mailbox); bool result = job->exec(); QEXPECT_FAIL("bad" , "Expected failure on BAD scenario", Continue); QEXPECT_FAIL("no" , "Expected failure on NO scenario", Continue); QVERIFY(result); QCOMPARE(job->mailBox(), mailbox); fakeServer.quit(); }
void testList() { QFETCH( bool, unsubscribed); QFETCH( QList<QByteArray>, scenario ); QFETCH( QList<KIMAP::MailBoxDescriptor>, listresult ); FakeServer fakeServer; fakeServer.setScenario( scenario ); fakeServer.startAndWait(); KIMAP::Session session( "127.0.0.1", 5989 ); KIMAP::ListJob *job = new KIMAP::ListJob( &session ); job->setIncludeUnsubscribed( unsubscribed ); QSignalSpy spy( job, SIGNAL(mailBoxesReceived(const QList<KIMAP::MailBoxDescriptor>&, const QList< QList<QByteArray> >&)) ); bool result = job->exec(); QEXPECT_FAIL( "bad" , "Expected failure on BAD response", Continue ); QEXPECT_FAIL( "no" , "Expected failure on NO response", Continue ); QVERIFY( result ); if ( result ) { QVERIFY( spy.count() > 0 ); QList<KIMAP::MailBoxDescriptor> mailBoxes; for ( int i = 0; i < spy.count(); i++ ) { mailBoxes+= spy.at( i ).at( 0 ).value< QList<KIMAP::MailBoxDescriptor> >(); } //kDebug() << mailBoxes.first().name; //kDebug() << listresult.first().name; QCOMPARE( mailBoxes, listresult ); } // QCOMPARE(job->mailBox(), mailbox); fakeServer.quit(); }
void testSingleSelect() { QFETCH(QList<QByteArray>, scenario); QFETCH(QList<QByteArray>, flags); QFETCH(QList<QByteArray>, permanentflags); QFETCH(int, messagecount); QFETCH(int, recentcount); QFETCH(int, firstUnseenIndex); QFETCH(qint64, uidValidity); QFETCH(qint64, nextUid); QFETCH(quint64, highestmodseq); QFETCH(bool, condstoreEnabled); FakeServer fakeServer; fakeServer.setScenario(scenario); fakeServer.startAndWait(); KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989); KIMAP::SelectJob *job = new KIMAP::SelectJob(&session); job->setCondstoreEnabled(condstoreEnabled); job->setMailBox(QStringLiteral("INBOX")); bool result = job->exec(); QEXPECT_FAIL("bad" , "Expected failure on BAD scenario", Continue); QEXPECT_FAIL("no" , "Expected failure on NO scenario", Continue); QVERIFY(result); if (result) { QCOMPARE(job->flags(), flags); QCOMPARE(job->permanentFlags(), permanentflags); QCOMPARE(job->messageCount(), messagecount); QCOMPARE(job->recentCount(), recentcount); QCOMPARE(job->firstUnseenIndex(), firstUnseenIndex); QCOMPARE(job->uidValidity(), uidValidity); QCOMPARE(job->nextUid(), nextUid); QCOMPARE(job->highestModSequence(), highestmodseq); } fakeServer.quit(); }
void metadata() { QFETCH(QList<QByteArray>, scenario); QFETCH(QString, mailbox); QFETCH(MAP, annotations); FakeServer fakeServer; fakeServer.setScenario(scenario); fakeServer.startAndWait(); KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989); KIMAP::SetMetaDataJob *setMetadataJob = new KIMAP::SetMetaDataJob(&session); setMetadataJob->setServerCapability(KIMAP::MetaDataJobBase::Metadata); setMetadataJob->setMailBox(mailbox); foreach (const QByteArray &entry, annotations.keys()) { setMetadataJob->addMetaData(entry, annotations[entry]); } QVERIFY(setMetadataJob->exec()); fakeServer.quit(); }
void testRename() { QFETCH( QString, mailbox ); QFETCH( QString, newname ); QFETCH( QList<QByteArray>, scenario ); FakeServer fakeServer; fakeServer.setScenario( scenario ); fakeServer.startAndWait(); KIMAP::Session session( "127.0.0.1", 5989 ); KIMAP::RenameJob *job = new KIMAP::RenameJob( &session ); job->setSourceMailBox( mailbox ); job->setDestinationMailBox( newname ); bool result = job->exec(); QEXPECT_FAIL( "bad" , "Expected failure on BAD response", Continue ); QEXPECT_FAIL( "no" , "Expected failure on NO response", Continue ); QVERIFY( result ); QCOMPARE( job->sourceMailBox(), mailbox ); QCOMPARE( job->destinationMailBox(), newname ); fakeServer.quit(); }