diff options
author | Shane Kearns <ext-shane.2.kearns@nokia.com> | 2012-04-10 14:38:21 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-10 19:39:21 (GMT) |
commit | 4807baf6401a629dbce81146af2a52182e74aac6 (patch) | |
tree | 3ea3095c3b67398f95345040238bbe397994c7bb | |
parent | 40760383969022be5488bb180dc7e1f8babcc0eb (diff) | |
download | Qt-4807baf6401a629dbce81146af2a52182e74aac6.zip Qt-4807baf6401a629dbce81146af2a52182e74aac6.tar.gz Qt-4807baf6401a629dbce81146af2a52182e74aac6.tar.bz2 |
Make QSslCertificate test fail instead of crash
If the SSL dlls could not be loaded, then QSslCertificate::fromPath
will return an empty list. Make the test check for this before
triggering an assertion failure by calling first()
Task-number: QTBUG-25229
Change-Id: Ib6280c02130142201016a3f15ddb6bd44bfa0f9f
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
-rw-r--r-- | tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index c73416d..ece379e 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -411,8 +411,10 @@ void tst_QSslCertificate::alternateSubjectNames() void tst_QSslCertificate::utf8SubjectNames() { - QSslCertificate cert = QSslCertificate::fromPath("certificates/cert-ss-san-utf8.pem", QSsl::Pem, - QRegExp::FixedString).first(); + QList<QSslCertificate> certs = QSslCertificate::fromPath("certificates/cert-ss-san-utf8.pem", QSsl::Pem, + QRegExp::FixedString); + QVERIFY(!certs.isEmpty()); + QSslCertificate cert = certs.first(); QVERIFY(!cert.isNull()); // O is "Heavy Metal Records" with heavy use of "decorations" like accents, umlauts etc., @@ -676,8 +678,10 @@ void tst_QSslCertificate::certInfo() "dc:c2:eb:b7:bb:50:18:05:ba:ad:af:08:49:fe:98:63" "55:ba:e7:fb:95:5d:91"; - QSslCertificate cert = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem, - QRegExp::FixedString).first(); + QList<QSslCertificate> certs = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem, + QRegExp::FixedString); + QVERIFY(!certs.isEmpty()); + QSslCertificate cert = certs.first(); QVERIFY(!cert.isNull()); QCOMPARE(cert.issuerInfo(QSslCertificate::Organization), QString("CryptSoft Pty Ltd")); @@ -733,8 +737,10 @@ void tst_QSslCertificate::certInfo() void tst_QSslCertificate::certInfoQByteArray() { - QSslCertificate cert = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem, - QRegExp::FixedString).first(); + QList<QSslCertificate> certs = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem, + QRegExp::FixedString); + QVERIFY(!certs.isEmpty()); + QSslCertificate cert = certs.first(); QVERIFY(!cert.isNull()); // in this test, check the bytearray variants before the enum variants to see if |