tst_QSslCertificate - improve code coverage
Some code-paths were never executed by auto-test, thus giving us LCOV's diagnostic. Extend existing tests and add new ones. Pick-to: 5.15 Change-Id: I648747547f0525a482216b1e1972fcc698c73f65 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
99abdd180b
commit
efd20cafe5
@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDnDCCAoQCCQDV3otC4hs2KTANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMC
|
||||
Tk8xDTALBgNVBAgTBE9zbG8xDTALBgNVBAcTBE9zbG8xDzANBgNVBAoTBlRUIEFT
|
||||
QTEOMAwGA1UECxMFUVQgU1cxHDAaBgNVBAMTE2FzcGlyaW5pa3MudHJvbGwubm8x
|
||||
IzAhBgkqhkiG9w0BCQEWFGFiYWJpY0B0cm9sbHRlY2guY29tMB4XDTA4MTEwMTA4
|
||||
NTcyOFoXDTA5MTEwMTA4NTcyOFowgY8xCzAJBgNVBAYTAk5PMQ0wCwYDVQQIEwRP
|
||||
c2xvMQ0wCwYDVQQHEwRPc2xvMQ8wDQYDVQQKEwZUVCBBU0ExDjAMBgNVBAsTBVFU
|
||||
IFNXMRwwGgYDVQQDExNhc3BpcmluaWtzLnRyb2xsLm5vMSMwIQYJKoZIhvcNAQkB
|
||||
FhRhYmFiaWNAdHJvbGx0ZWNoLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
|
||||
AQoCggEBAMV2bMD1DN3DMgbxU3DXw2i7EWGDXcWjTDtdHvqgIb+9nHqo3MJSrzJy
|
||||
qgEPoOsXqswMla9wDPZAsWv5gVAmVSqpy2lfEgfY7LaSHiGD75seF7zIy+CxREHW
|
||||
DofHXpJGGJpBCZEKQt2HfHu3+yAYNPucN78tWNZAcPbUg5tfxMZeepRimAZNIxBI
|
||||
93SDrl/f9Ka7hvPSzUQsnp8hfdpHlFPFznKfD6yPrjxgz2mT9efavJ4DhtyIa4m+
|
||||
pai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zr1w4swiqAtIcNauRoiQ1Gh7m3881AxQXT2pYKpl3zu268sx33i
|
||||
XIBcXoRdwBvy80Ave0Z+nihZU6R+CXJtb9xl4kfJof8cgagAkuNLRpY9OW6n8rBo
|
||||
yX9mwg7z8tKV+2AaUJl+kiRfhujLmoohouP34/LdTHXTdIh1O0Jwx36QY4ara9ER
|
||||
QsQjUmnmWJREvwzzUVsqcOOduHPEJyz5wIDFpw2KLR+8N2i6/jBs9/dWps476Ohj
|
||||
b9+y/tXKcWt+ja9MGvw0Bn8pqU8r4Kj3aYM8KzezRSEL7KKPSNFKkOZYzRYwGkXn
|
||||
O+ZIyasjjO/C4aSlpZCgWQ1B400ZlrXKmEiFJpkGBnQP/offQJKeSxlfnWwOQ4Og
|
||||
0TsWxr+VMy7uRq8ltTKbE0UvHPQqf9AmkQ==
|
||||
-----END CERTIFICATE-----
|
@ -0,0 +1,31 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFZTCCA02gAwIBAgIUDufSooDGcwmx5dTWzw76lAH4m+EwDQYJKoZIhvcNAQEL
|
||||
BQAwQTELMAkGA1UEBhMCTk8xDTALBgNVBAgMBE9zbG8xDTALBgNVBAcMBE9zbG8x
|
||||
FDASBgNVBAsMC0ZvdW5kYXRpb25zMCAXDTIwMTExOTEzMjczM1oYDzIxMjAxMDI2
|
||||
MTMyNzMzWjBBMQswCQYDVQQGEwJOTzENMAsGA1UECAwET3NsbzENMAsGA1UEBwwE
|
||||
T3NsbzEUMBIGA1UECwwLRm91bmRhdGlvbnMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
|
||||
DwAwggIKAoICAQDEtFnz4VNkh/4eX8jh/QWaJXR8lMliZ/CBqheresvlQPIVpO/i
|
||||
iDsPeY6eZazko/B0NOoM+oJ0PBGepC8AJOdHf6peo4iNXiA7odczUBUoC1ALal03
|
||||
V1KbRfATPYiDaPAUWg1nyEnb5DymLeX0lEwRitPxobYzIw00h/YpHnABj8MwyyNM
|
||||
vgk+wYrPC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Yc/TUl9qAIlXaY9KN5k+GuSLrxIdA9VII3GvuRg
|
||||
u2ghKl0xgC+uHfLwlfAxJwWbLyJS/ji3Y5yADc700D++pjZI1rWaC7jbOjH0wocA
|
||||
DW2tQY6Eh4MA1xQyj2IF24j+wfBNdWg/Ndc9BvCuG00v1qAje7lAZOuA8P2977SS
|
||||
0zqdgSbkAM83c4O6+kWaiRFb8pPBciSxR0YwIchxjjJWSlcqop6cJxtOKhvG+RQX
|
||||
oLIkpHJznI8aXK5rEniDb6YJm7o+a0i5cQkJQht1lDPI9WW5d7sliozrm1s+pmcr
|
||||
AM2KHvDxb9Pur6jIOqm9mvYpI3llJu2ICcp/HKiRI0iVV2a/bd1YQzY=
|
||||
-----END CERTIFICATE-----
|
@ -80,6 +80,9 @@ private slots:
|
||||
void subjectAlternativeNames_data();
|
||||
void utf8SubjectNames();
|
||||
void subjectAlternativeNames();
|
||||
void subjectInfoToString();
|
||||
void subjectIssuerDisplayName_data();
|
||||
void subjectIssuerDisplayName();
|
||||
void publicKey_data();
|
||||
void publicKey();
|
||||
void toPemOrDer_data();
|
||||
@ -437,6 +440,63 @@ void tst_QSslCertificate::subjectAlternativeNames()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::subjectInfoToString()
|
||||
{
|
||||
QFile certFile(testDataDir + "more-certificates/aspiriniks.ca.crt");
|
||||
const bool ok = certFile.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
const auto chain = QSslCertificate::fromDevice(&certFile, QSsl::Pem);
|
||||
QCOMPARE(chain.size(), 1);
|
||||
const auto cert = chain.at(0);
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
const auto testInfo = [&cert](QSslCertificate::SubjectInfo info, const QString &expected) {
|
||||
const auto infoAsList = cert.subjectInfo(info);
|
||||
if (infoAsList.size())
|
||||
return expected == infoAsList.at(0);
|
||||
return expected == QString();
|
||||
};
|
||||
|
||||
QVERIFY(testInfo(QSslCertificate::Organization, QStringLiteral("TT ASA")));
|
||||
QVERIFY(testInfo(QSslCertificate::CommonName, QStringLiteral("aspiriniks.troll.no")));
|
||||
QVERIFY(testInfo(QSslCertificate::LocalityName, QStringLiteral("Oslo")));
|
||||
QVERIFY(testInfo(QSslCertificate::OrganizationalUnitName, QStringLiteral("QT SW")));
|
||||
QVERIFY(testInfo(QSslCertificate::CountryName, QStringLiteral("NO")));
|
||||
QVERIFY(testInfo(QSslCertificate::StateOrProvinceName, QStringLiteral("Oslo")));
|
||||
QVERIFY(testInfo(QSslCertificate::DistinguishedNameQualifier, QString()));
|
||||
QVERIFY(testInfo(QSslCertificate::SerialNumber, QString()));
|
||||
#ifndef QT_NO_OPENSSL
|
||||
// TODO: check why generic code does not handle this!
|
||||
QVERIFY(testInfo(QSslCertificate::EmailAddress, QStringLiteral("ababic@trolltech.com")));
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::subjectIssuerDisplayName_data()
|
||||
{
|
||||
QTest::addColumn<QString>("certName");
|
||||
QTest::addColumn<QString>("expectedName");
|
||||
|
||||
QTest::addRow("CommonName") << QStringLiteral("more-certificates/cert-cn.pem") << QStringLiteral("YOUR name");
|
||||
QTest::addRow("OrganizationName") << QStringLiteral("more-certificates/cert-on.pem") << QStringLiteral("R&D");
|
||||
QTest::addRow("OrganizationUnitName") << QStringLiteral("more-certificates/cert-oun.pem") << QStringLiteral("Foundations");
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QTest::addRow("NoSubjectName") << QStringLiteral("more-certificates/cert-noname.pem") << QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::subjectIssuerDisplayName()
|
||||
{
|
||||
QFETCH(const QString, certName);
|
||||
QFETCH(const QString, expectedName);
|
||||
|
||||
const auto chain = QSslCertificate::fromPath(testDataDir + certName);
|
||||
QCOMPARE(chain.size(), 1);
|
||||
const auto cert = chain.at(0);
|
||||
QVERIFY(!cert.isNull());
|
||||
QCOMPARE(cert.subjectDisplayName(), expectedName);
|
||||
QCOMPARE(cert.issuerDisplayName(), expectedName);
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::utf8SubjectNames()
|
||||
{
|
||||
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert-ss-san-utf8.pem", QSsl::Pem,
|
||||
@ -545,8 +605,15 @@ void tst_QSslCertificate::toPemOrDer()
|
||||
void tst_QSslCertificate::fromDevice()
|
||||
{
|
||||
QTest::ignoreMessage(QtWarningMsg, "QSslCertificate::fromDevice: cannot read from a null device");
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromDevice(0); // don't crash
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromDevice(nullptr); // don't crash
|
||||
QVERIFY(certs.isEmpty());
|
||||
|
||||
QFile certFile(testDataDir + "certificates/cert.der");
|
||||
const bool ok = certFile.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
const auto chain = QSslCertificate::fromDevice(&certFile, QSsl::Der);
|
||||
QCOMPARE(chain.size(), 1);
|
||||
QVERIFY(!chain.at(0).isNull());
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::fromPath_qregularexpression_data()
|
||||
|
Loading…
Reference in New Issue
Block a user