[PATCH] Add test using the default download server used by the software

Wald Commits scm-commit at wald.intevation.org
Mon Sep 1 13:14:13 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1409570050 -7200
# Node ID 8fb1b912fd8e22ca784cd7cbb9e22015d543d885
# Parent  561cc777e0b6131b1dbfe00dbeebd4323cdba459
Add test using the default download server used by the software

    This should help to highlight problems in the real environement
    but needs to be adapted when the server / server layout changes
    just as the software..

diff -r 561cc777e0b6 -r 8fb1b912fd8e CMakeLists.txt
--- a/CMakeLists.txt	Mon Sep 01 12:53:22 2014 +0200
+++ b/CMakeLists.txt	Mon Sep 01 13:14:10 2014 +0200
@@ -12,6 +12,7 @@
 option(ENABLE_PROFILING "Set to enable profiling." OFF)
 option(USE_CURL "Use libcurl to download updates and certificate lists." ON)
 
+set(DOWNLOAD_SERVER "https://files.intevation.de:443" CACHE STRING "Used as download server" )
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
 
 #Old qtmain linking behavior to be compatible with cmake versions < 2.8.11
diff -r 561cc777e0b6 -r 8fb1b912fd8e ui/CMakeLists.txt
--- a/ui/CMakeLists.txt	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/CMakeLists.txt	Mon Sep 01 13:14:10 2014 +0200
@@ -11,6 +11,9 @@
 include_directories(${CMAKE_BINARY_DIR}/common)
 add_definitions(${Qt5Widgets_DEFINITIONS})
 
+message(STATUS "Using ${DOWNLOAD_SERVER} as download server for updates.")
+add_definitions(-DSERVER_URL="${DOWNLOAD_SERVER}")
+
 find_package(Qt5LinguistTools)
 find_package(CURL)
 
diff -r 561cc777e0b6 -r 8fb1b912fd8e ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/mainwindow.cpp	Mon Sep 01 13:14:10 2014 +0200
@@ -55,7 +55,9 @@
 #define APPNAME "TrustBridge"
 #endif
 
-#define SERVER_URL "https://files.intevation.de:443"
+#ifndef SERVER_URL
+#error "DOWNLOAD_SERVER option not set or invalid."
+#endif
 
 #if defined(_X86_) || defined(__i386__)
 #define TB_ARCH_STRING "-i386"
diff -r 561cc777e0b6 -r 8fb1b912fd8e ui/tests/downloadertest.cpp
--- a/ui/tests/downloadertest.cpp	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/tests/downloadertest.cpp	Mon Sep 01 13:14:10 2014 +0200
@@ -228,6 +228,40 @@
     delete downloader;
 }
 
+void DownloaderTest::testDefaultUrl()
+{
+    /* This test might fail if SERVER_URL is configured differently
+     * and needs to be adapted once there is a public download server. 
+     * This test also needs internet connectivity. */
+    Downloader* downloader = new Downloader(this,
+            QString::fromLatin1(SERVER_URL),
+            QByteArray(),
+            QDateTime::currentDateTime(), // Last installed SW
+            QDateTime::fromString("2010", "YYYY"),
+            QString("/users/aheinecke/zertifikatsliste.txt"),
+            QString("/users/aheinecke/zertifikatsliste.txt"));
+
+    SETUP_SPY
+
+    connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
+            this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
+
+    downloader->start();
+
+    int waited = 0;
+    while (newListAvailable.count() == 0 &&
+            errors.count() == 0  && waited < 20) {
+        QTest::qWait(200);
+        waited++;
+    }
+    QVERIFY(waited != 20);
+    QVERIFY(newListAvailable.count() == 1);
+    QVERIFY(newSoftwareAvailable.count() == 0);
+    QVERIFY(errors.count() == 0);
+
+    delete downloader;
+}
+
 void DownloaderTest::testNewList()
 {
     QFile validCert(QString::fromLatin1(SOURCE_DIR) +
diff -r 561cc777e0b6 -r 8fb1b912fd8e ui/tests/downloadertest.h
--- a/ui/tests/downloadertest.h	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/tests/downloadertest.h	Mon Sep 01 13:14:10 2014 +0200
@@ -37,6 +37,7 @@
     void testOtherCertificate();
     void testNewSoftware();
     void testForcedCiphers();
+    void testDefaultUrl();
 };
 #endif
 


More information about the Trustbridge-commits mailing list