File indexing completed on 2024-05-12 05:17:19
0001 /* 0002 Copyright (c) 2015 Christian Mollekopf <mollekopf@kolabsys.com> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "kimap2test/fakeserver.h" 0020 #include "kimap2/session.h" 0021 #include "kimap2/idjob.h" 0022 0023 #include <QTcpSocket> 0024 #include <QtTest> 0025 0026 typedef QMap<QByteArray, QByteArray> ArrayMap; 0027 Q_DECLARE_METATYPE(ArrayMap) 0028 0029 class IdJobTest: public QObject { 0030 Q_OBJECT 0031 0032 private Q_SLOTS: 0033 0034 void testId_data() { 0035 QTest::addColumn<QList<QByteArray> >("scenario"); 0036 QTest::addColumn<ArrayMap>("values"); 0037 QList<QByteArray> scenario; 0038 scenario << "S: * PREAUTH" 0039 << "C: A000001 ID (\"name\" \"clientid\")" 0040 << "S: * ID NIL" 0041 << "S: A000001 OK ID completed"; 0042 0043 ArrayMap values; 0044 values.insert("name", "clientid"); 0045 QTest::newRow("good") << scenario << values; 0046 } 0047 0048 void testId() 0049 { 0050 QFETCH(QList<QByteArray>, scenario); 0051 QFETCH(ArrayMap, values); 0052 0053 FakeServer fakeServer; 0054 fakeServer.setScenario(scenario); 0055 fakeServer.startAndWait(); 0056 KIMAP2::Session session(QStringLiteral("127.0.0.1"), 5989); 0057 0058 KIMAP2::IdJob *job = new KIMAP2::IdJob(&session); 0059 foreach (const QByteArray &key, values.keys()) { 0060 job->setField(key, values.value(key)); 0061 } 0062 bool result = job->exec(); 0063 QVERIFY(result); 0064 fakeServer.quit(); 0065 } 0066 0067 }; 0068 0069 QTEST_GUILESS_MAIN(IdJobTest) 0070 0071 #include "idjobtest.moc"