comparison ui/tests/downloadertest.cpp @ 990:2949f1842955

(issue90) Add possibility to force cipher suites in bare connection and test for this
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 01 Sep 2014 12:04:11 +0200
parents eaed02defe6a
children 8fb1b912fd8e
comparison
equal deleted inserted replaced
989:1cd1bfe82fc2 990:2949f1842955
7 */ 7 */
8 #include "downloadertest.h" 8 #include "downloadertest.h"
9 #include "downloader.h" 9 #include "downloader.h"
10 #include "common.h" 10 #include "common.h"
11 11
12 #include <polarssl/ssl_ciphersuites.h>
12 #include <QTextStream> 13 #include <QTextStream>
13 #include <QFile> 14 #include <QFile>
14 #include <QVariant> 15 #include <QVariant>
15 #include <unistd.h> 16 #include <unistd.h>
16 17
146 int error = arguments.at(1).toInt(); 147 int error = arguments.at(1).toInt();
147 148
148 QVERIFY(error == SSLConnection::NoConnection); 149 QVERIFY(error == SSLConnection::NoConnection);
149 } 150 }
150 151
152 void DownloaderTest::testForcedCiphers()
153 {
154 Downloader* downloader = new Downloader(this,
155 QString::fromLatin1("https://files.intevation.de:443"),
156 QByteArray(), /* Use default testing certificate */
157 QDateTime::currentDateTime(),
158 QDateTime::fromString("2010", "YYYY"),
159 "/users/aheinecke/development/TrustBridge-development.exe",
160 "/users/aheinecke/development/zertifikatsliste.txt");
161 int accept_ciphers[] = {
162 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
163 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
164 TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
165 0
166 };
167
168 downloader->setCiphersuites(accept_ciphers);
169
170 SETUP_SPY
171
172 downloader->start();
173
174 int waited = 0;
175 while (errors.count() == 0 && waited < MAX_WAIT) {
176 QTest::qWait(200);
177 waited++;
178 }
179 QVERIFY(waited != MAX_WAIT);
180 QVERIFY(newListAvailable.count() == 0);
181 QVERIFY(newSoftwareAvailable.count() == 0);
182
183 QList<QVariant> arguments = errors.takeFirst();
184
185 int error = arguments.at(1).toInt();
186
187 QVERIFY(error == SSLConnection::SSLHandshakeFailed);
188 }
189
151 void DownloaderTest::testNewSoftware() 190 void DownloaderTest::testNewSoftware()
152 { 191 {
153 QFile validCert(QString::fromLatin1(SOURCE_DIR) + 192 QFile validCert(QString::fromLatin1(SOURCE_DIR) +
154 "/data/valid_ssl_bp.pem"); 193 "/data/valid_ssl_bp.pem");
155 validCert.open(QIODevice::ReadOnly); 194 validCert.open(QIODevice::ReadOnly);

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