summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-28 14:13:03 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-28 14:13:03 +0100
commit2a9b02ff6d2279f7cd301ae1f397d275afa66922 (patch)
treea5089fb9b7ec31cebc248c9617c664e839dec641 /examples
parent7ec52003ec7f06cbb8897cd70e8d952ead3ca15f (diff)
downloadsink-2a9b02ff6d2279f7cd301ae1f397d275afa66922.tar.gz
sink-2a9b02ff6d2279f7cd301ae1f397d275afa66922.zip
Fixed imap tests
Adjust to cyrus imap settings and use explicit encryption setting.
Diffstat (limited to 'examples')
-rw-r--r--examples/imapresource/imapresource.cpp26
-rw-r--r--examples/imapresource/imapserverproxy.cpp15
-rw-r--r--examples/imapresource/imapserverproxy.h9
-rw-r--r--examples/imapresource/tests/imapmailsynctest.cpp16
-rw-r--r--examples/imapresource/tests/imapmailtest.cpp4
-rw-r--r--examples/imapresource/tests/imapserverproxytest.cpp28
-rw-r--r--examples/imapresource/tests/populatemailbox.sh2
-rw-r--r--examples/imapresource/tests/resetmailbox.sh5
8 files changed, 68 insertions, 37 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index 14c3a3e..cd3b69f 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -526,7 +526,7 @@ public:
526 526
527 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE 527 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE
528 { 528 {
529 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); 529 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, mEncryptionMode, &mSessionCache);
530 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { 530 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) {
531 return login(imap) 531 return login(imap)
532 .then([=] { 532 .then([=] {
@@ -634,7 +634,7 @@ public:
634 return KAsync::null<QByteArray>(); 634 return KAsync::null<QByteArray>();
635 } 635 }
636 } 636 }
637 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); 637 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, mEncryptionMode, &mSessionCache);
638 auto login = imap->login(mUser, secret()); 638 auto login = imap->login(mUser, secret());
639 KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); 639 KAsync::Job<QByteArray> job = KAsync::null<QByteArray>();
640 if (operation == Sink::Operation_Creation) { 640 if (operation == Sink::Operation_Creation) {
@@ -719,7 +719,7 @@ public:
719 return KAsync::error<QByteArray>("Tried to replay modification without old remoteId."); 719 return KAsync::error<QByteArray>("Tried to replay modification without old remoteId.");
720 } 720 }
721 } 721 }
722 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, &mSessionCache); 722 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, mEncryptionMode, &mSessionCache);
723 auto login = imap->login(mUser, secret()); 723 auto login = imap->login(mUser, secret());
724 if (operation == Sink::Operation_Creation) { 724 if (operation == Sink::Operation_Creation) {
725 QString parentFolder; 725 QString parentFolder;
@@ -793,6 +793,7 @@ public:
793public: 793public:
794 QString mServer; 794 QString mServer;
795 int mPort; 795 int mPort;
796 Imap::EncryptionMode mEncryptionMode = Imap::NoEncryption;
796 QString mUser; 797 QString mUser;
797 int mDaysToSync = 0; 798 int mDaysToSync = 0;
798 QByteArray mResourceInstanceIdentifier; 799 QByteArray mResourceInstanceIdentifier;
@@ -839,7 +840,7 @@ protected:
839 } 840 }
840 KIMAP2::FetchJob::FetchScope scope; 841 KIMAP2::FetchJob::FetchScope scope;
841 scope.mode = KIMAP2::FetchJob::FetchScope::Full; 842 scope.mode = KIMAP2::FetchJob::FetchScope::Full;
842 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 843 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, mEncryptionMode);
843 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); 844 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create();
844 SinkTrace() << "Connecting to:" << mServer << mPort; 845 SinkTrace() << "Connecting to:" << mServer << mPort;
845 SinkTrace() << "as:" << mUser; 846 SinkTrace() << "as:" << mUser;
@@ -907,7 +908,7 @@ protected:
907 auto set = KIMAP2::ImapSet::fromImapSequenceSet("1:*"); 908 auto set = KIMAP2::ImapSet::fromImapSequenceSet("1:*");
908 KIMAP2::FetchJob::FetchScope scope; 909 KIMAP2::FetchJob::FetchScope scope;
909 scope.mode = KIMAP2::FetchJob::FetchScope::Headers; 910 scope.mode = KIMAP2::FetchJob::FetchScope::Headers;
910 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 911 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, mEncryptionMode);
911 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); 912 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create();
912 return imap->login(mUser, secret()) 913 return imap->login(mUser, secret())
913 .then(imap->select(remoteId)) 914 .then(imap->select(remoteId))
@@ -925,7 +926,7 @@ protected:
925 auto folderByPath = QSharedPointer<QSet<QString>>::create(); 926 auto folderByPath = QSharedPointer<QSet<QString>>::create();
926 auto folderByName = QSharedPointer<QSet<QString>>::create(); 927 auto folderByName = QSharedPointer<QSet<QString>>::create();
927 928
928 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 929 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort, mEncryptionMode);
929 auto inspectionJob = imap->login(mUser, secret()) 930 auto inspectionJob = imap->login(mUser, secret())
930 .then(imap->fetchFolders([=](const Imap::Folder &f) { 931 .then(imap->fetchFolders([=](const Imap::Folder &f) {
931 *folderByPath << f.path(); 932 *folderByPath << f.path();
@@ -950,6 +951,7 @@ protected:
950public: 951public:
951 QString mServer; 952 QString mServer;
952 int mPort; 953 int mPort;
954 Imap::EncryptionMode mEncryptionMode = Imap::NoEncryption;
953 QString mUser; 955 QString mUser;
954}; 956};
955 957
@@ -962,6 +964,16 @@ ImapResource::ImapResource(const ResourceContext &resourceContext)
962 auto port = config.value("port").toInt(); 964 auto port = config.value("port").toInt();
963 auto user = config.value("username").toString(); 965 auto user = config.value("username").toString();
964 auto daysToSync = config.value("daysToSync", 14).toInt(); 966 auto daysToSync = config.value("daysToSync", 14).toInt();
967 auto starttls = config.value("starttls", false).toBool();
968
969 auto encryption = Imap::NoEncryption;
970 if (server.startsWith("imaps")) {
971 encryption = Imap::Tls;
972 }
973 if (starttls) {
974 encryption = Imap::Starttls;
975 }
976
965 if (server.startsWith("imap")) { 977 if (server.startsWith("imap")) {
966 server.remove("imap://"); 978 server.remove("imap://");
967 server.remove("imaps://"); 979 server.remove("imaps://");
@@ -975,6 +987,7 @@ ImapResource::ImapResource(const ResourceContext &resourceContext)
975 auto synchronizer = QSharedPointer<ImapSynchronizer>::create(resourceContext); 987 auto synchronizer = QSharedPointer<ImapSynchronizer>::create(resourceContext);
976 synchronizer->mServer = server; 988 synchronizer->mServer = server;
977 synchronizer->mPort = port; 989 synchronizer->mPort = port;
990 synchronizer->mEncryptionMode = encryption;
978 synchronizer->mUser = user; 991 synchronizer->mUser = user;
979 synchronizer->mDaysToSync = daysToSync; 992 synchronizer->mDaysToSync = daysToSync;
980 setupSynchronizer(synchronizer); 993 setupSynchronizer(synchronizer);
@@ -982,6 +995,7 @@ ImapResource::ImapResource(const ResourceContext &resourceContext)
982 auto inspector = QSharedPointer<ImapInspector>::create(resourceContext); 995 auto inspector = QSharedPointer<ImapInspector>::create(resourceContext);
983 inspector->mServer = server; 996 inspector->mServer = server;
984 inspector->mPort = port; 997 inspector->mPort = port;
998 inspector->mEncryptionMode = encryption;
985 inspector->mUser = user; 999 inspector->mUser = user;
986 setupInspector(inspector); 1000 setupInspector(inspector);
987 1001
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index 9a84327..2dd2d46 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -136,13 +136,20 @@ KIMAP2::Session *createNewSession(const QString &serverUrl, int port)
136 return newSession; 136 return newSession;
137} 137}
138 138
139ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr) 139ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port, EncryptionMode encryptionMode, SessionCache *sessionCache) : mSessionCache(sessionCache), mSession(nullptr), mEncryptionMode(encryptionMode)
140{ 140{
141 if (!mSessionCache || mSessionCache->isEmpty()) { 141 if (!mSessionCache || mSessionCache->isEmpty()) {
142 mSession = createNewSession(serverUrl, port); 142 mSession = createNewSession(serverUrl, port);
143 } 143 }
144} 144}
145 145
146QDebug operator<<(QDebug debug, const KIMAP2::MailBoxDescriptor &c)
147{
148 QDebugStateSaver saver(debug);
149 debug.nospace() << c.name;
150 return debug;
151}
152
146KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) 153KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password)
147{ 154{
148 if (password.isEmpty()) { 155 if (password.isEmpty()) {
@@ -164,12 +171,12 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString
164 auto loginJob = new KIMAP2::LoginJob(mSession); 171 auto loginJob = new KIMAP2::LoginJob(mSession);
165 loginJob->setUserName(username); 172 loginJob->setUserName(username);
166 loginJob->setPassword(password); 173 loginJob->setPassword(password);
167 loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain); 174 if (mEncryptionMode == Starttls) {
168 if (mSession->port() == 143) {
169 loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true); 175 loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true);
170 } else { 176 } else if (mEncryptionMode == Tls) {
171 loginJob->setEncryptionMode(QSsl::AnyProtocol, false); 177 loginJob->setEncryptionMode(QSsl::AnyProtocol, false);
172 } 178 }
179 loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain);
173 180
174 auto capabilitiesJob = new KIMAP2::CapabilitiesJob(mSession); 181 auto capabilitiesJob = new KIMAP2::CapabilitiesJob(mSession);
175 QObject::connect(capabilitiesJob, &KIMAP2::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) { 182 QObject::connect(capabilitiesJob, &KIMAP2::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) {
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 7044a5e..0dc6e55 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -246,9 +246,15 @@ private:
246 QList<CachedSession> mSessions; 246 QList<CachedSession> mSessions;
247}; 247};
248 248
249enum EncryptionMode {
250 NoEncryption,
251 Tls,
252 Starttls
253};
254
249class ImapServerProxy { 255class ImapServerProxy {
250public: 256public:
251 ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache = nullptr); 257 ImapServerProxy(const QString &serverUrl, int port, EncryptionMode encryption, SessionCache *sessionCache = nullptr);
252 258
253 //Standard IMAP calls 259 //Standard IMAP calls
254 KAsync::Job<void> login(const QString &username, const QString &password); 260 KAsync::Job<void> login(const QString &username, const QString &password);
@@ -305,6 +311,7 @@ private:
305 KIMAP2::Session *mSession; 311 KIMAP2::Session *mSession;
306 QStringList mCapabilities; 312 QStringList mCapabilities;
307 Namespaces mNamespaces; 313 Namespaces mNamespaces;
314 EncryptionMode mEncryptionMode;
308}; 315};
309 316
310} 317}
diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp
index 23bb4e5..cdb85dd 100644
--- a/examples/imapresource/tests/imapmailsynctest.cpp
+++ b/examples/imapresource/tests/imapmailsynctest.cpp
@@ -43,7 +43,7 @@ protected:
43 bool isBackendAvailable() Q_DECL_OVERRIDE 43 bool isBackendAvailable() Q_DECL_OVERRIDE
44 { 44 {
45 QTcpSocket socket; 45 QTcpSocket socket;
46 socket.connectToHost("localhost", 993); 46 socket.connectToHost("localhost", 143);
47 return socket.waitForConnected(200); 47 return socket.waitForConnected(200);
48 } 48 }
49 49
@@ -56,7 +56,7 @@ protected:
56 { 56 {
57 auto resource = ApplicationDomain::ImapResource::create("account1"); 57 auto resource = ApplicationDomain::ImapResource::create("account1");
58 resource.setProperty("server", "localhost"); 58 resource.setProperty("server", "localhost");
59 resource.setProperty("port", 993); 59 resource.setProperty("port", 143);
60 resource.setProperty("username", "doe"); 60 resource.setProperty("username", "doe");
61 Sink::SecretStore::instance().insert(resource.identifier(), "doe"); 61 Sink::SecretStore::instance().insert(resource.identifier(), "doe");
62 return resource; 62 return resource;
@@ -67,7 +67,7 @@ protected:
67 auto resource = ApplicationDomain::ImapResource::create("account1"); 67 auto resource = ApplicationDomain::ImapResource::create("account1");
68 //Using a bogus ip instead of a bogus hostname avoids getting stuck in the hostname lookup 68 //Using a bogus ip instead of a bogus hostname avoids getting stuck in the hostname lookup
69 resource.setProperty("server", "111.111.1.1"); 69 resource.setProperty("server", "111.111.1.1");
70 resource.setProperty("port", 993); 70 resource.setProperty("port", 143);
71 resource.setProperty("username", "doe"); 71 resource.setProperty("username", "doe");
72 Sink::SecretStore::instance().insert(resource.identifier(), "doe"); 72 Sink::SecretStore::instance().insert(resource.identifier(), "doe");
73 return resource; 73 return resource;
@@ -80,21 +80,21 @@ protected:
80 80
81 void createFolder(const QStringList &folderPath) Q_DECL_OVERRIDE 81 void createFolder(const QStringList &folderPath) Q_DECL_OVERRIDE
82 { 82 {
83 Imap::ImapServerProxy imap("localhost", 993); 83 Imap::ImapServerProxy imap("localhost", 143, Imap::NoEncryption);
84 VERIFYEXEC(imap.login("doe", "doe")); 84 VERIFYEXEC(imap.login("doe", "doe"));
85 VERIFYEXEC(imap.create("INBOX." + folderPath.join('.'))); 85 VERIFYEXEC(imap.create("INBOX." + folderPath.join('.')));
86 } 86 }
87 87
88 void removeFolder(const QStringList &folderPath) Q_DECL_OVERRIDE 88 void removeFolder(const QStringList &folderPath) Q_DECL_OVERRIDE
89 { 89 {
90 Imap::ImapServerProxy imap("localhost", 993); 90 Imap::ImapServerProxy imap("localhost", 143, Imap::NoEncryption);
91 VERIFYEXEC(imap.login("doe", "doe")); 91 VERIFYEXEC(imap.login("doe", "doe"));
92 VERIFYEXEC(imap.remove("INBOX." + folderPath.join('.'))); 92 VERIFYEXEC(imap.remove("INBOX." + folderPath.join('.')));
93 } 93 }
94 94
95 QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) Q_DECL_OVERRIDE 95 QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) Q_DECL_OVERRIDE
96 { 96 {
97 Imap::ImapServerProxy imap("localhost", 993); 97 Imap::ImapServerProxy imap("localhost", 143, Imap::NoEncryption);
98 VERIFYEXEC_RET(imap.login("doe", "doe"), {}); 98 VERIFYEXEC_RET(imap.login("doe", "doe"), {});
99 VERIFYEXEC_RET(imap.append("INBOX." + folderPath.join('.'), message), {}); 99 VERIFYEXEC_RET(imap.append("INBOX." + folderPath.join('.'), message), {});
100 return "2:*"; 100 return "2:*";
@@ -102,14 +102,14 @@ protected:
102 102
103 void removeMessage(const QStringList &folderPath, const QByteArray &messages) Q_DECL_OVERRIDE 103 void removeMessage(const QStringList &folderPath, const QByteArray &messages) Q_DECL_OVERRIDE
104 { 104 {
105 Imap::ImapServerProxy imap("localhost", 993); 105 Imap::ImapServerProxy imap("localhost", 143, Imap::NoEncryption);
106 VERIFYEXEC(imap.login("doe", "doe")); 106 VERIFYEXEC(imap.login("doe", "doe"));
107 VERIFYEXEC(imap.remove("INBOX." + folderPath.join('.'), messages)); 107 VERIFYEXEC(imap.remove("INBOX." + folderPath.join('.'), messages));
108 } 108 }
109 109
110 void markAsImportant(const QStringList &folderPath, const QByteArray &messageIdentifier) Q_DECL_OVERRIDE 110 void markAsImportant(const QStringList &folderPath, const QByteArray &messageIdentifier) Q_DECL_OVERRIDE
111 { 111 {
112 Imap::ImapServerProxy imap("localhost", 993); 112 Imap::ImapServerProxy imap("localhost", 143, Imap::NoEncryption);
113 VERIFYEXEC(imap.login("doe", "doe")); 113 VERIFYEXEC(imap.login("doe", "doe"));
114 VERIFYEXEC(imap.select("INBOX." + folderPath.join('.'))); 114 VERIFYEXEC(imap.select("INBOX." + folderPath.join('.')));
115 VERIFYEXEC(imap.addFlags(KIMAP2::ImapSet::fromImapSequenceSet(messageIdentifier), QByteArrayList() << Imap::Flags::Flagged)); 115 VERIFYEXEC(imap.addFlags(KIMAP2::ImapSet::fromImapSequenceSet(messageIdentifier), QByteArrayList() << Imap::Flags::Flagged));
diff --git a/examples/imapresource/tests/imapmailtest.cpp b/examples/imapresource/tests/imapmailtest.cpp
index 60ec1bf..6616811 100644
--- a/examples/imapresource/tests/imapmailtest.cpp
+++ b/examples/imapresource/tests/imapmailtest.cpp
@@ -23,7 +23,7 @@ protected:
23 bool isBackendAvailable() Q_DECL_OVERRIDE 23 bool isBackendAvailable() Q_DECL_OVERRIDE
24 { 24 {
25 QTcpSocket socket; 25 QTcpSocket socket;
26 socket.connectToHost("localhost", 993); 26 socket.connectToHost("localhost", 143);
27 return socket.waitForConnected(200); 27 return socket.waitForConnected(200);
28 } 28 }
29 29
@@ -36,7 +36,7 @@ protected:
36 { 36 {
37 auto resource = ApplicationDomain::ImapResource::create("account1"); 37 auto resource = ApplicationDomain::ImapResource::create("account1");
38 resource.setProperty("server", "localhost"); 38 resource.setProperty("server", "localhost");
39 resource.setProperty("port", 993); 39 resource.setProperty("port", 143);
40 resource.setProperty("username", "doe"); 40 resource.setProperty("username", "doe");
41 Sink::SecretStore::instance().insert(resource.identifier(), "doe"); 41 Sink::SecretStore::instance().insert(resource.identifier(), "doe");
42 return resource; 42 return resource;
diff --git a/examples/imapresource/tests/imapserverproxytest.cpp b/examples/imapresource/tests/imapserverproxytest.cpp
index 271b3d9..999665f 100644
--- a/examples/imapresource/tests/imapserverproxytest.cpp
+++ b/examples/imapresource/tests/imapserverproxytest.cpp
@@ -25,7 +25,7 @@ private slots:
25 { 25 {
26 Sink::Test::initTest(); 26 Sink::Test::initTest();
27 QTcpSocket socket; 27 QTcpSocket socket;
28 socket.connectToHost("localhost", 993); 28 socket.connectToHost("localhost", 143);
29 QVERIFY(socket.waitForConnected(200)); 29 QVERIFY(socket.waitForConnected(200));
30 system("resetmailbox.sh"); 30 system("resetmailbox.sh");
31 } 31 }
@@ -43,45 +43,47 @@ private slots:
43 43
44 void testLogin() 44 void testLogin()
45 { 45 {
46 ImapServerProxy imap("localhost", 993); 46 ImapServerProxy imap("localhost", 143, Imap::EncryptionMode::NoEncryption);
47 VERIFYEXEC(imap.login("doe", "doe")); 47 VERIFYEXEC(imap.login("doe", "doe"));
48 } 48 }
49 49
50 void testLoginFailure() 50 void testLoginFailure()
51 { 51 {
52 //Using a bogus ip instead of a bogus hostname avoids getting stuck in the hostname lookup 52 //Using a bogus ip instead of a bogus hostname avoids getting stuck in the hostname lookup
53 ImapServerProxy imap("111.111.1.1", 993); 53 ImapServerProxy imap("111.111.1.1", 143, Imap::EncryptionMode::NoEncryption);
54 VERIFYEXEC_FAIL(imap.login("doe", "doe")); 54 VERIFYEXEC_FAIL(imap.login("doe", "doe"));
55 } 55 }
56 56
57 void testFetchFolders() 57 void testFetchFolders()
58 { 58 {
59 QMap<QString, QString> expectedFolderAndParent; 59 QMap<QString, QString> expectedFolderAndParent {
60 expectedFolderAndParent.insert("INBOX", ""); 60 {"INBOX", ""},
61 expectedFolderAndParent.insert("Drafts", ""); 61 {"Drafts", ""},
62 expectedFolderAndParent.insert("Trash", ""); 62 {"Trash", ""},
63 expectedFolderAndParent.insert("test", ""); 63 {"test", ""}
64 ImapServerProxy imap("localhost", 993); 64 };
65 ImapServerProxy imap("localhost", 143, Imap::EncryptionMode::NoEncryption);
65 VERIFYEXEC(imap.login("doe", "doe")); 66 VERIFYEXEC(imap.login("doe", "doe"));
66 QVector<Folder> list; 67 QVector<Folder> list;
67 VERIFYEXEC(imap.fetchFolders([&](const Folder &f){ list << f;})); 68 VERIFYEXEC(imap.fetchFolders([&](const Folder &f){ list << f;}));
68 for (const auto &f : list) { 69 for (const auto &f : list) {
69 QVERIFY(expectedFolderAndParent.contains(f.name())); 70 QVERIFY2(expectedFolderAndParent.contains(f.name()), QString{"Didn't expect folder %1"}.arg(f.name()).toUtf8());
70 QCOMPARE(expectedFolderAndParent.value(f.name()), f.parentPath()); 71 QCOMPARE(expectedFolderAndParent.value(f.name()), f.parentPath());
71 expectedFolderAndParent.remove(f.name()); 72 expectedFolderAndParent.remove(f.name());
72 } 73 }
73 QVERIFY(expectedFolderAndParent.isEmpty()); 74 QVERIFY(expectedFolderAndParent.isEmpty());
75//examples/imapresource/tests/imapserverproxytest testFetchFolders
74 } 76 }
75 77
76 void testFetchFoldersFailure() 78 void testFetchFoldersFailure()
77 { 79 {
78 ImapServerProxy imap("foobar", 993); 80 ImapServerProxy imap("foobar", 143, Imap::EncryptionMode::NoEncryption);
79 VERIFYEXEC_FAIL(imap.fetchFolders([](const Folder &){})); 81 VERIFYEXEC_FAIL(imap.fetchFolders([](const Folder &){}));
80 } 82 }
81 83
82 void testFetchMail() 84 void testFetchMail()
83 { 85 {
84 ImapServerProxy imap("localhost", 993); 86 ImapServerProxy imap("localhost", 143, Imap::EncryptionMode::NoEncryption);
85 VERIFYEXEC(imap.login("doe", "doe")); 87 VERIFYEXEC(imap.login("doe", "doe"));
86 88
87 KIMAP2::FetchJob::FetchScope scope; 89 KIMAP2::FetchJob::FetchScope scope;
@@ -98,7 +100,7 @@ private slots:
98 100
99 void testRemoveMail() 101 void testRemoveMail()
100 { 102 {
101 ImapServerProxy imap("localhost", 993); 103 ImapServerProxy imap("localhost", 143, Imap::EncryptionMode::NoEncryption);
102 VERIFYEXEC(imap.login("doe", "doe")); 104 VERIFYEXEC(imap.login("doe", "doe"));
103 VERIFYEXEC(imap.remove("INBOX.test", "1:*")); 105 VERIFYEXEC(imap.remove("INBOX.test", "1:*"));
104 106
diff --git a/examples/imapresource/tests/populatemailbox.sh b/examples/imapresource/tests/populatemailbox.sh
index 0889790..a5949fc 100644
--- a/examples/imapresource/tests/populatemailbox.sh
+++ b/examples/imapresource/tests/populatemailbox.sh
@@ -23,7 +23,7 @@ sudo echo "sub INBOX.Trash" | cyradm --auth PLAIN -u doe -w doe localhost
23# # sudo cp /src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S /var/spool/imap/d/user/doe/test/$i. 23# # sudo cp /src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S /var/spool/imap/d/user/doe/test/$i.
24# done 24# done
25# Because this is way faster than a loop 25# Because this is way faster than a loop
26FOLDERPATH=/var/spool/imap/u/'user^doe^test' 26FOLDERPATH=/var/spool/imap/d/user/doe/test
27sudo tee </src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S >/dev/null $FOLDERPATH/{1..1000}. 27sudo tee </src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S >/dev/null $FOLDERPATH/{1..1000}.
28sudo tee </src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S >/dev/null $FOLDERPATH/{1001..2000}. 28sudo tee </src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S >/dev/null $FOLDERPATH/{1001..2000}.
29sudo tee </src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S >/dev/null $FOLDERPATH/{2001..3000}. 29sudo tee </src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S >/dev/null $FOLDERPATH/{2001..3000}.
diff --git a/examples/imapresource/tests/resetmailbox.sh b/examples/imapresource/tests/resetmailbox.sh
index f3a9391..8e6b1b1 100644
--- a/examples/imapresource/tests/resetmailbox.sh
+++ b/examples/imapresource/tests/resetmailbox.sh
@@ -9,6 +9,7 @@ sudo echo "subscribe INBOX.Drafts" | cyradm --auth PLAIN -u doe -w doe localhost
9sudo echo "cm user.doe.Trash" | cyradm --auth PLAIN -u cyrus -w admin localhost 9sudo echo "cm user.doe.Trash" | cyradm --auth PLAIN -u cyrus -w admin localhost
10sudo echo "subscribe INBOX.Trash" | cyradm --auth PLAIN -u doe -w doe localhost 10sudo echo "subscribe INBOX.Trash" | cyradm --auth PLAIN -u doe -w doe localhost
11sudo echo "sam user.doe cyrus c" | cyradm --auth PLAIN -u cyrus -w admin localhost 11sudo echo "sam user.doe cyrus c" | cyradm --auth PLAIN -u cyrus -w admin localhost
12sudo cp /src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S /var/spool/imap/u/'user^doe^test'/1. 12FOLDERPATH=/var/spool/imap/d/user/doe/test
13sudo chown cyrus:mail /var/spool/imap/u/'user^doe^test'/1. 13sudo cp /src/sink/examples/imapresource/tests/data/1365777830.R28.localhost.localdomain\:2\,S $FOLDERPATH/1.
14sudo chown cyrus:mail $FOLDERPATH/1.
14sudo reconstruct "user.doe.test" 15sudo reconstruct "user.doe.test"