summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qsslcertificate/tst_qsslcertificate.cpp')
-rw-r--r--tests/auto/qsslcertificate/tst_qsslcertificate.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
index 9276685928..6e29072d8f 100644
--- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
@@ -113,6 +113,7 @@ private slots:
void largeSerialNumber();
void largeExpirationDate();
void blacklistedCertificates();
+ void toText();
// ### add tests for certificate bundles (multiple certificates concatenated into a single
// structure); both PEM and DER formatted
@@ -850,6 +851,26 @@ void tst_QSslCertificate::blacklistedCertificates()
}
}
+void tst_QSslCertificate::toText()
+{
+ QList<QSslCertificate> certList =
+ QSslCertificate::fromPath(SRCDIR "more-certificates/cert-large-expiration-date.pem");
+
+ QCOMPARE(certList.size(), 1);
+ const QSslCertificate &cert = certList.at(0);
+
+ // Openssl's cert dump method changed slightly between 0.9.8 and 1.0.0 versions, so we want it to match any output
+
+ QFile fOld(SRCDIR "more-certificates/cert-large-expiration-date.txt.0.9.8");
+ QVERIFY(fOld.open(QIODevice::ReadOnly));
+ QByteArray txtOld = fOld.readAll();
+
+ QFile fNew(SRCDIR "more-certificates/cert-large-expiration-date.txt.1.0.0");
+ QVERIFY(fNew.open(QIODevice::ReadOnly));
+ QByteArray txtNew = fNew.readAll();
+ QVERIFY(txtOld == cert.toText() || txtNew == cert.toText());
+}
+
#endif // QT_NO_OPENSSL
QTEST_MAIN(tst_QSslCertificate)