diff 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
line wrap: on
line diff
--- a/ui/tests/downloadertest.cpp	Fri Aug 29 19:18:31 2014 +0200
+++ b/ui/tests/downloadertest.cpp	Mon Sep 01 12:04:11 2014 +0200
@@ -9,6 +9,7 @@
 #include "downloader.h"
 #include "common.h"
 
+#include <polarssl/ssl_ciphersuites.h>
 #include <QTextStream>
 #include <QFile>
 #include <QVariant>
@@ -148,6 +149,44 @@
     QVERIFY(error == SSLConnection::NoConnection);
 }
 
+void DownloaderTest::testForcedCiphers()
+{
+    Downloader* downloader = new Downloader(this,
+            QString::fromLatin1("https://files.intevation.de:443"),
+            QByteArray(), /* Use default testing certificate */
+            QDateTime::currentDateTime(),
+            QDateTime::fromString("2010", "YYYY"),
+            "/users/aheinecke/development/TrustBridge-development.exe",
+            "/users/aheinecke/development/zertifikatsliste.txt");
+    int accept_ciphers[] = {
+        TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
+        TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
+        TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
+        0
+    };
+
+    downloader->setCiphersuites(accept_ciphers);
+
+    SETUP_SPY
+
+    downloader->start();
+
+    int waited = 0;
+    while (errors.count() == 0  && waited < MAX_WAIT) {
+        QTest::qWait(200);
+        waited++;
+    }
+    QVERIFY(waited != MAX_WAIT);
+    QVERIFY(newListAvailable.count() == 0);
+    QVERIFY(newSoftwareAvailable.count() == 0);
+
+    QList<QVariant> arguments = errors.takeFirst();
+
+    int error = arguments.at(1).toInt();
+
+    QVERIFY(error == SSLConnection::SSLHandshakeFailed);
+}
+
 void DownloaderTest::testNewSoftware()
 {
     QFile validCert(QString::fromLatin1(SOURCE_DIR) +

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