summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/tests/imapserverproxytest.cpp
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/imapresource/tests/imapserverproxytest.cpp
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/imapresource/tests/imapserverproxytest.cpp')
-rw-r--r--examples/imapresource/tests/imapserverproxytest.cpp28
1 files changed, 15 insertions, 13 deletions
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