comparison 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
comparison
equal deleted inserted replaced
51:78633b2b580c 52:d73a2f0170d4
70 70
71 retval = (file1.readAll() == file2.readAll()); 71 retval = (file1.readAll() == file2.readAll());
72 file1.close(); 72 file1.close();
73 file2.close(); 73 file2.close();
74 return retval; 74 return retval;
75 }
76
77 void DownloaderTest::testOtherCertificate()
78 {
79 QFile otherCert(QString::fromLatin1(SOURCE_DIR) +
80 "/data/valid_ssl_rsa.pem");
81 otherCert.open(QIODevice::ReadOnly);
82
83 Downloader* downloader = new Downloader(this,
84 QString::fromLatin1("https://localhost:44443"),
85 otherCert.readAll(),
86 QDateTime::currentDateTime(), // Last installed SW
87 QDateTime::fromString("2010", "YYYY"),
88 "/garbage_2MB",
89 "/list-valid.txt");
90 otherCert.close();
91
92 SETUP_SPY
93
94 downloader->start();
95
96 int waited = 0;
97 while (errors.count() == 0 && waited < MAX_WAIT) {
98 QTest::qWait(200);
99 waited++;
100 }
101 QVERIFY(waited != MAX_WAIT);
102 QVERIFY(newListAvailable.count() == 0);
103 QVERIFY(newSoftwareAvailable.count() == 0);
104
105 QList<QVariant> arguments = errors.takeFirst();
106
107 int error = arguments.at(1).toInt();
108
109 QVERIFY(error == SSLConnection::InvalidCertificate);
75 } 110 }
76 111
77 void DownloaderTest::testNoConnection() 112 void DownloaderTest::testNoConnection()
78 { 113 {
79 Downloader* downloader = new Downloader(this, 114 Downloader* downloader = new Downloader(this,

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