Mercurial > trustbridge
diff ui/tests/downloadertest.cpp @ 52:d73a2f0170d4
Add test for another certificate
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 17 Mar 2014 11:38:42 +0000 |
parents | 78633b2b580c |
children | 64200b011dfd |
line wrap: on
line diff
--- 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<QVariant> arguments = errors.takeFirst(); + + int error = arguments.at(1).toInt(); + + QVERIFY(error == SSLConnection::InvalidCertificate); +} + void DownloaderTest::testNoConnection() { Downloader* downloader = new Downloader(this,