File indexing completed on 2024-05-12 05:17:19
0001 /* 0002 Copyright (C) 2016 Daniel Vrátil <dvratil@kde.org> 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 <qtest.h> 0020 0021 #include "kimap2test/fakeserver.h" 0022 #include "kimap2/session.h" 0023 #include "kimap2/expungejob.h" 0024 0025 #include <QtTest> 0026 0027 class ExpungeJobTest: public QObject 0028 { 0029 Q_OBJECT 0030 0031 private Q_SLOTS: 0032 0033 void testDelete_data() 0034 { 0035 QTest::addColumn<QList<QByteArray> >("scenario"); 0036 0037 QList<QByteArray> scenario; 0038 scenario << FakeServer::preauth() 0039 << "C: A000001 EXPUNGE" 0040 << "S: * 1 EXPUNGE" 0041 << "S: * 2 EXPUNGE" 0042 << "S: * 3 EXPUNGE" 0043 << "S: A000001 OK EXPUNGE completed"; 0044 QTest::newRow("good") << scenario; 0045 0046 scenario.clear(); 0047 scenario << FakeServer::preauth() 0048 << "C: A000001 EXPUNGE" 0049 << "S: * 1" // missing EXPUNGE word 0050 << "S: A000001 OK EXPUNGE completed"; 0051 QTest::newRow("non-standard response") << scenario; 0052 0053 scenario.clear(); 0054 scenario << FakeServer::preauth() 0055 << "C: A000001 EXPUNGE" 0056 << "S: A000001 BAD command unknown or arguments invalid"; 0057 QTest::newRow("bad") << scenario; 0058 0059 scenario.clear(); 0060 scenario << FakeServer::preauth() 0061 << "C: A000001 EXPUNGE" 0062 << "S: A000001 NO access deined"; 0063 QTest::newRow("no") << scenario; 0064 } 0065 0066 void testDelete() 0067 { 0068 QFETCH(QList<QByteArray>, scenario); 0069 0070 FakeServer fakeServer; 0071 fakeServer.setScenario(scenario); 0072 fakeServer.startAndWait(); 0073 0074 KIMAP2::Session session(QStringLiteral("127.0.0.1"), 5989); 0075 0076 KIMAP2::ExpungeJob *job = new KIMAP2::ExpungeJob(&session); 0077 bool result = job->exec(); 0078 QEXPECT_FAIL("bad" , "Expected failure on BAD response", Continue); 0079 QEXPECT_FAIL("no" , "Expected failure on NO response", Continue); 0080 QVERIFY(result); 0081 0082 fakeServer.quit(); 0083 } 0084 0085 }; 0086 0087 QTEST_GUILESS_MAIN(ExpungeJobTest) 0088 0089 #include "expungejobtest.moc"