Skip to content

Commit

Permalink
Add an autotest the QSslCertificate::version() method works.
Browse files Browse the repository at this point in the history
Change-Id: Ife5b7206fd3d7af57cfca3c0f28f56bb53ede7a7
Reviewed-by: Jeremy Lainé <[email protected]>
Reviewed-by: Peter Hartmann <[email protected]>
  • Loading branch information
richmoore authored and The Qt Project committed May 6, 2014
1 parent cfacdae commit 1d66954
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ private slots:
void verify();
void extensions();
void threadSafeConstMethods();
void version_data();
void version();

// helper for verbose test failure messages
QString toString(const QList<QSslError>&);
Expand Down Expand Up @@ -1150,6 +1152,33 @@ void tst_QSslCertificate::threadSafeConstMethods()

}

void tst_QSslCertificate::version_data()
{
QTest::addColumn<QSslCertificate>("certificate");
QTest::addColumn<QByteArray>("result");

QTest::newRow("null certificate") << QSslCertificate() << QByteArray();

QList<QSslCertificate> certs;
certs << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");

QTest::newRow("v3 certificate") << certs.first() << QByteArrayLiteral("3");

certs.clear();
certs << QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem");
QTest::newRow("v1 certificate") << certs.first() << QByteArrayLiteral("1");
}

void tst_QSslCertificate::version()
{
if (!QSslSocket::supportsSsl())
return;

QFETCH(QSslCertificate, certificate);
QFETCH(QByteArray, result);
QCOMPARE(certificate.version(), result);
}

#endif // QT_NO_SSL

QTEST_MAIN(tst_QSslCertificate)
Expand Down

0 comments on commit 1d66954

Please sign in to comment.