# HG changeset patch # User Andre Heinecke # Date 1395056322 0 # Node ID d73a2f0170d483131899f94845ca92c8fc4d1a35 # Parent 78633b2b580c57a18ee1e202993606a992fa2cf7 Add test for another certificate diff -r 78633b2b580c -r d73a2f0170d4 ui/tests/downloadertest.cpp --- a/ui/tests/downloadertest.cpp Mon Mar 17 11:38:13 2014 +0000 +++ b/ui/tests/downloadertest.cpp Mon Mar 17 11:38:42 2014 +0000 @@ -74,6 +74,41 @@ return retval; } +void DownloaderTest::testOtherCertificate() +{ + QFile otherCert(QString::fromLatin1(SOURCE_DIR) + + "/data/valid_ssl_rsa.pem"); + otherCert.open(QIODevice::ReadOnly); + + Downloader* downloader = new Downloader(this, + QString::fromLatin1("https://localhost:44443"), + otherCert.readAll(), + QDateTime::currentDateTime(), // Last installed SW + QDateTime::fromString("2010", "YYYY"), + "/garbage_2MB", + "/list-valid.txt"); + otherCert.close(); + + 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 arguments = errors.takeFirst(); + + int error = arguments.at(1).toInt(); + + QVERIFY(error == SSLConnection::InvalidCertificate); +} + void DownloaderTest::testNoConnection() { Downloader* downloader = new Downloader(this, diff -r 78633b2b580c -r d73a2f0170d4 ui/tests/downloadertest.h --- a/ui/tests/downloadertest.h Mon Mar 17 11:38:13 2014 +0000 +++ b/ui/tests/downloadertest.h Mon Mar 17 11:38:42 2014 +0000 @@ -26,6 +26,7 @@ void cleanupTestCase(); void testNewList(); void testNoConnection(); + void testOtherCertificate(); }; #endif