Add autotest for the QSslCertificate QIODevice constructor.

Change-Id: I92fa083665509932b75ff1037904a6f78a950fd6
Reviewed-by: Jeremy Lainé <jeremy.laine@m4x.org>
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
Richard J. Moore 2014-05-05 16:42:14 +01:00 committed by The Qt Project
parent 1d6695451f
commit 9b1746c499

View File

@ -81,6 +81,7 @@ private slots:
void emptyConstructor();
void constructor_data();
void constructor();
void constructor_device();
void constructingGarbage();
void copyAndAssign_data();
void copyAndAssign();
@ -227,6 +228,47 @@ void tst_QSslCertificate::constructor()
QVERIFY(!certificate.isNull());
}
void tst_QSslCertificate::constructor_device()
{
if (!QSslSocket::supportsSsl())
return;
QFile f(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
bool ok = f.open(QIODevice::ReadOnly);
QVERIFY(ok);
QSslCertificate cert(&f);
QVERIFY(!cert.isNull());
f.close();
// Check opening a DER as a PEM fails
QFile f2(testDataDir + "/certificates/cert.der");
ok = f2.open(QIODevice::ReadOnly);
QVERIFY(ok);
QSslCertificate cert2(&f2);
QVERIFY(cert2.isNull());
f2.close();
// Check opening a DER as a DER works
QFile f3(testDataDir + "/certificates/cert.der");
ok = f3.open(QIODevice::ReadOnly);
QVERIFY(ok);
QSslCertificate cert3(&f3, QSsl::Der);
QVERIFY(!cert3.isNull());
f3.close();
// Check opening a PEM as a DER fails
QFile f4(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
ok = f4.open(QIODevice::ReadOnly);
QVERIFY(ok);
QSslCertificate cert4(&f4, QSsl::Der);
QVERIFY(cert4.isNull());
f4.close();
}
void tst_QSslCertificate::constructingGarbage()
{
if (!QSslSocket::supportsSsl())