annotate ui/tests/downloadertest.cpp @ 1131:521032de3a0a

(auto) Update translations
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 17 Sep 2014 13:39:02 +0200
parents 508c96e72f62
children
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 240
diff changeset
7 */
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 #include "downloadertest.h"
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 #include "downloader.h"
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
10 #include "common.h"
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11
990
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
12 #include <polarssl/ssl_ciphersuites.h>
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 #include <QTextStream>
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 #include <QFile>
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
15 #include <QVariant>
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
16 #include <unistd.h>
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17
51
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
18 #define MAX_WAIT 20
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
19
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
20 #define SETUP_SPY \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
21 QSignalSpy newListAvailable(downloader, \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
22 SIGNAL(newListAvailable(const QString&, const QDateTime&))); \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
23 QSignalSpy newSoftwareAvailable(downloader, \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
24 SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&))); \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
25 QSignalSpy errors(downloader, SIGNAL(error(const QString &, \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
26 SSLConnection::ErrorCode))); \
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
27
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 void DownloaderTest::startServer(QString additionalOptions)
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 QFile serverConfig(serverConfigDir.path() + "/" + "hiawatha.conf");
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 QFile mimeConfig(serverConfigDir.path() + "/" + "mimetype.conf");
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 if (serverProc.state() == QProcess::Running) {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 serverProc.close();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 serverConfig.open(QIODevice::WriteOnly);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 mimeConfig.open(QIODevice::WriteOnly);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 mimeConfig.close(); /* just an empty file */
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 QTextStream configStream(&serverConfig);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 configStream <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 "Binding { " << endl <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 "Port = 44443 " << endl <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 "SSLcertFile = " << SOURCE_DIR <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 "/data/valid_ssl_bp_priv.pem" << endl <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 "Interface = 127.0.0.1" << endl <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 "}" << endl <<
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 "Hostname = 127.0.0.1" << endl <<
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
48 "WebsiteRoot = " << serverConfigDir.path() << endl;
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 configStream.flush();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 serverConfig.close();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 serverProc.start();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 serverProc.waitForStarted();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 void DownloaderTest::initTestCase() {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 QStringList arguments;
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 serverProc.setProgram(HIAWATHA_EXECUTABLE);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 arguments << "-d" << "-c" << serverConfigDir.path();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 serverProc.setArguments(arguments);
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 43
diff changeset
61 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode");
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 startServer();
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
63 garbageInfo = QFileInfo(getRandomDataFile(2 * 1024, serverConfigDir.path()));
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
64 QVERIFY(QFile::copy(QString::fromLocal8Bit(SOURCE_DIR"/data/list-valid.txt"),
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
65 serverConfigDir.path() + "/" + "list-valid.txt"));
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
66
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 QTest::qWait(1000); /* Wait for the server to settle */
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 43
diff changeset
70 void DownloaderTest::downloaderError(const QString &message, SSLConnection::ErrorCode error)
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 qDebug() << "Downloader Error: " << error << " Msg: " << message;
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74
47
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
75 bool filesEqual(QString filename1, QString filename2)
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
76 {
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
77 bool retval = false;
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
78 QFile file1(filename1);
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
79 QFile file2(filename2);
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
80 file1.open(QIODevice::ReadOnly);
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
81 file2.open(QIODevice::ReadOnly);
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
82
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
83 retval = (file1.readAll() == file2.readAll());
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
84 file1.close();
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
85 file2.close();
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
86 return retval;
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
87 }
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
88
52
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
89 void DownloaderTest::testOtherCertificate()
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
90 {
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
91 QFile otherCert(QString::fromLatin1(SOURCE_DIR) +
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
92 "/data/valid_ssl_rsa.pem");
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
93 otherCert.open(QIODevice::ReadOnly);
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
94
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
95 QFileInfo fi(getRandomDataFile(200));
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
96
52
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
97 Downloader* downloader = new Downloader(this,
910
eaed02defe6a More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
98 QString::fromLatin1("https://127.0.0.1:44443"),
52
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
99 otherCert.readAll(),
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
100 QDateTime::currentDateTime(), // Last installed SW
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
101 QDateTime::fromString("2010", "YYYY"),
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
102 "/" + garbageInfo.fileName(),
52
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
103 "/list-valid.txt");
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
104 otherCert.close();
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
105
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
106 SETUP_SPY
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
107
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
108 downloader->start();
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
109
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
110 int waited = 0;
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
111 while (errors.count() == 0 && waited < MAX_WAIT) {
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
112 QTest::qWait(200);
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
113 waited++;
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
114 }
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
115 QVERIFY(waited != MAX_WAIT);
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
116 QVERIFY(newListAvailable.count() == 0);
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
117 QVERIFY(newSoftwareAvailable.count() == 0);
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
118
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
119 QList<QVariant> arguments = errors.takeFirst();
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
120
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
121 int error = arguments.at(1).toInt();
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
122
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
123 QVERIFY(error == SSLConnection::InvalidCertificate);
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
124 }
d73a2f0170d4 Add test for another certificate
Andre Heinecke <aheinecke@intevation.de>
parents: 51
diff changeset
125
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
126 void DownloaderTest::testNoConnection()
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
127 {
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
128 Downloader* downloader = new Downloader(this,
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
129 QString::fromLatin1("https://foobar.intevation.de"));
51
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
130
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
131 SETUP_SPY
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
132
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
133 downloader->start();
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
134
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
135 int waited = 0;
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
136 while (newListAvailable.count() == 0 &&
51
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
137 errors.count() == 0 && waited < MAX_WAIT) {
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
138 QTest::qWait(200);
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
139 waited++;
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
140 }
51
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
141 QVERIFY(waited != MAX_WAIT);
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
142 QVERIFY(newListAvailable.count() == 0);
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
143 QVERIFY(newSoftwareAvailable.count() == 0);
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
144
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
145 QList<QVariant> arguments = errors.takeFirst();
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
146
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
147 int error = arguments.at(1).toInt();
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
148
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
149 QVERIFY(error == SSLConnection::NoConnection);
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
150 }
999
daa9448b64f5 (issue90) Use certificate pinning and forced ciphersuites for curl
Andre Heinecke <andre.heinecke@intevation.de>
parents: 994
diff changeset
151 static int accept_ciphers[] = {
1088
508c96e72f62 (issue124) Switch server URL and remove some RELEASE_BUILD options
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1058
diff changeset
152 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256,
999
daa9448b64f5 (issue90) Use certificate pinning and forced ciphersuites for curl
Andre Heinecke <andre.heinecke@intevation.de>
parents: 994
diff changeset
153 0
daa9448b64f5 (issue90) Use certificate pinning and forced ciphersuites for curl
Andre Heinecke <andre.heinecke@intevation.de>
parents: 994
diff changeset
154 };
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
155
990
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
156 void DownloaderTest::testForcedCiphers()
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
157 {
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
158 Downloader* downloader = new Downloader(this,
999
daa9448b64f5 (issue90) Use certificate pinning and forced ciphersuites for curl
Andre Heinecke <andre.heinecke@intevation.de>
parents: 994
diff changeset
159 QString::fromLatin1(SERVER_URL),
990
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
160 QByteArray(), /* Use default testing certificate */
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
161 QDateTime::currentDateTime(),
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
162 QDateTime::fromString("2010", "YYYY"),
1088
508c96e72f62 (issue124) Switch server URL and remove some RELEASE_BUILD options
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1058
diff changeset
163 "/development/TrustBridge-development.exe",
508c96e72f62 (issue124) Switch server URL and remove some RELEASE_BUILD options
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1058
diff changeset
164 "/development/zertifikatsliste.txt");
990
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
165
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
166 downloader->setCiphersuites(accept_ciphers);
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
167
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
168 SETUP_SPY
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
169
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
170 downloader->start();
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
171
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
172 int waited = 0;
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
173 while (errors.count() == 0 && waited < MAX_WAIT) {
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
174 QTest::qWait(200);
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
175 waited++;
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
176 }
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
177 QVERIFY(waited != MAX_WAIT);
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
178 QVERIFY(newListAvailable.count() == 0);
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
179 QVERIFY(newSoftwareAvailable.count() == 0);
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
180
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
181 QList<QVariant> arguments = errors.takeFirst();
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
182
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
183 int error = arguments.at(1).toInt();
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
184
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
185 QVERIFY(error == SSLConnection::SSLHandshakeFailed);
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
186 }
2949f1842955 (issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents: 910
diff changeset
187
55
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
188 void DownloaderTest::testNewSoftware()
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
189 {
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
190 QFile validCert(QString::fromLatin1(SOURCE_DIR) +
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
191 "/data/valid_ssl_bp.pem");
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
192 validCert.open(QIODevice::ReadOnly);
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
193
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
194 Downloader* downloader = new Downloader(this,
910
eaed02defe6a More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
195 QString::fromLatin1("https://127.0.0.1:44443"),
55
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
196 validCert.readAll(),
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
197 QDateTime::fromString("2010", "YYYY"),
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
198 QDateTime::currentDateTime(),
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
199 "/" + garbageInfo.fileName(),
55
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
200 "/list-valid.txt");
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
201 validCert.close();
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
202
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
203 SETUP_SPY
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
204
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
205 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
206 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
207
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
208 downloader->start();
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
209
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
210 int waited = 0;
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
211 while (newSoftwareAvailable.count() == 0 &&
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
212 errors.count() == 0 && waited < 20) {
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
213 QTest::qWait(200);
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
214 waited++;
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
215 }
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
216 QVERIFY(waited != 20);
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
217 QVERIFY(newListAvailable.count() == 0);
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
218 QVERIFY(newSoftwareAvailable.count() == 1);
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
219 QVERIFY(errors.count() == 0);
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
220
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
221 QList<QVariant> arguments = newSoftwareAvailable.takeFirst();
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
222
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
223 QVERIFY(filesEqual(serverConfigDir.path() + "/" + garbageInfo.fileName(),
55
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
224 arguments.at(0).toString()));
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
225
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
226 delete downloader;
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
227 }
64200b011dfd Add test for software download
Andre Heinecke <aheinecke@intevation.de>
parents: 52
diff changeset
228
994
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
229 void DownloaderTest::testDefaultUrl()
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
230 {
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
231 /* This test might fail if SERVER_URL is configured differently
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
232 * and needs to be adapted once there is a public download server.
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
233 * This test also needs internet connectivity. */
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
234 Downloader* downloader = new Downloader(this,
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
235 QString::fromLatin1(SERVER_URL),
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
236 QByteArray(),
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
237 QDateTime::currentDateTime(), // Last installed SW
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
238 QDateTime::fromString("2010", "YYYY"),
1088
508c96e72f62 (issue124) Switch server URL and remove some RELEASE_BUILD options
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1058
diff changeset
239 QString("/zertifikatsliste.txt"),
508c96e72f62 (issue124) Switch server URL and remove some RELEASE_BUILD options
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1058
diff changeset
240 QString("/zertifikatsliste.txt"));
994
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
241
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
242 SETUP_SPY
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
243
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
244 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
245 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
246
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
247 downloader->start();
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
248
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
249 int waited = 0;
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
250 while (newListAvailable.count() == 0 &&
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
251 errors.count() == 0 && waited < 20) {
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
252 QTest::qWait(200);
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
253 waited++;
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
254 }
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
255 QVERIFY(waited != 20);
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
256 QVERIFY(newListAvailable.count() == 1);
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
257 QVERIFY(newSoftwareAvailable.count() == 0);
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
258 QVERIFY(errors.count() == 0);
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
259
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
260 delete downloader;
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
261 }
8fb1b912fd8e Add test using the default download server used by the software
Andre Heinecke <andre.heinecke@intevation.de>
parents: 990
diff changeset
262
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
263 void DownloaderTest::testNewList()
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
264 {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
265 QFile validCert(QString::fromLatin1(SOURCE_DIR) +
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
266 "/data/valid_ssl_bp.pem");
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
267 validCert.open(QIODevice::ReadOnly);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
268
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
269 Downloader* downloader = new Downloader(this,
910
eaed02defe6a More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
270 QString::fromLatin1("https://127.0.0.1:44443"),
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
271 validCert.readAll(),
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
272 QDateTime::currentDateTime(), // Last installed SW
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
273 QDateTime::fromString("2010", "YYYY"),
240
c05e126b0b9e Fix downloadertest and factor out generating file input.
Andre Heinecke <aheinecke@intevation.de>
parents: 55
diff changeset
274 "/" + garbageInfo.fileName(),
46
d28e2624c1d5 Reset connection before the next request.
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
275 "/list-valid.txt");
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
276 validCert.close();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
277
51
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
278 SETUP_SPY
78633b2b580c Add macro for common signal setup tasks
Andre Heinecke <aheinecke@intevation.de>
parents: 50
diff changeset
279
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 43
diff changeset
280 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 43
diff changeset
281 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
282
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
283 downloader->start();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
284
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
285 int waited = 0;
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
286 while (newListAvailable.count() == 0 &&
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
287 errors.count() == 0 && waited < 20) {
48
3f8c2d46ded6 Add test for no connection handling
Andre Heinecke <aheinecke@intevation.de>
parents: 47
diff changeset
288 QTest::qWait(200);
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
289 waited++;
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
290 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
291 QVERIFY(waited != 20);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
292 QVERIFY(newListAvailable.count() == 1);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
293 QVERIFY(newSoftwareAvailable.count() == 0);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
294 QVERIFY(errors.count() == 0);
47
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
295
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
296 QList<QVariant> arguments = newListAvailable.takeFirst();
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
297
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
298 QVERIFY(filesEqual(QString::fromLatin1(SOURCE_DIR) + "/data/list-valid.txt",
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
299 arguments.at(0).toString()));
7e37c6033c81 Verify that the downloaded file matches the served one
Andre Heinecke <aheinecke@intevation.de>
parents: 46
diff changeset
300
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
301 delete downloader;
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
302 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
303
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
304 void DownloaderTest::cleanupTestCase() {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
305 if (serverProc.state() == QProcess::Running) {
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
306 serverProc.close();
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
307 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
308 }
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
309
1058
fe2c6666b462 (issue46) Add debug option to trustbridge client application
Andre Heinecke <andre.heinecke@intevation.de>
parents: 999
diff changeset
310 bool g_debug = true;
fe2c6666b462 (issue46) Add debug option to trustbridge client application
Andre Heinecke <andre.heinecke@intevation.de>
parents: 999
diff changeset
311
43
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
312 QTEST_GUILESS_MAIN (DownloaderTest);
5910bf9016cd Add Downloadertest
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
313

http://wald.intevation.org/projects/trustbridge/