summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/tests
diff options
context:
space:
mode:
Diffstat (limited to 'examples/imapresource/tests')
-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
5 files changed, 29 insertions, 26 deletions
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"