mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-31 01:30:02 +02:00
Import qt-certificate-addon
This commit is contained in:
7
thirdparty/qt-certificate-addon/tests/auto/auto.pro
vendored
Normal file
7
thirdparty/qt-certificate-addon/tests/auto/auto.pro
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += keybuilder \
|
||||
certificaterequest \
|
||||
certificaterequestbuilder
|
||||
|
||||
|
1
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/.gitignore
vendored
Normal file
1
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tst_certificaterequest
|
11
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/certificaterequest.pro
vendored
Normal file
11
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/certificaterequest.pro
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
TEMPLATE = app
|
||||
TARGET = tst_certificaterequest
|
||||
|
||||
CONFIG += testcase
|
||||
QT += testlib network
|
||||
|
||||
LIBS += -Wl,-rpath,../../../src/certificate -L../../../src/certificate -lcertificate
|
||||
INCLUDEPATH += ../../../src/certificate
|
||||
|
||||
SOURCES += tst_certificaterequest.cpp
|
||||
|
12
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/requests/test-ocsp-good-req.pem
vendored
Normal file
12
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/requests/test-ocsp-good-req.pem
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
-----BEGIN NEW CERTIFICATE REQUEST-----
|
||||
MIIBtTCCAR4CAQAwdTEUMBIGA1UEAxMLZXhhbXBsZS5jb20xEzARBgNVBAgTCkxh
|
||||
bmNhc2hpcmUxCzAJBgNVBAYTAlVLMR8wHQYJKoZIhvcNAQkBFhB0ZXN0QGV4YW1w
|
||||
bGUuY29tMRowGAYDVQQKExFTb21lIG9yZ2FuaXNhdGlvbjCBnzANBgkqhkiG9w0B
|
||||
AQEFAAOBjQAwgYkCgYEAl8mSJ4GnTGSCojDWB7dX4JzqzetTvuq2tUdm0GhUJaft
|
||||
IVzc/dpB9sfANa6Xcv2Lryk9OFpnizmKzoYlDzintTizjoHw6nmZy/UjZFXzS6S2
|
||||
I2Qp6rrzKVKnfzLcDbbZ1OYT3gFBhpotj7sMGIgJrNRq6cuKF4qFCaauphwF6VUC
|
||||
AwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIubgGHRO9Whcf0caMrZ7aUtGfVj8Okj
|
||||
RVOBlqUlVADhWUrWKHR1yV3j4+HDwpzQ5JemMcvLKH46m+c9OCnM6L904RxK0ZrJ
|
||||
qPcRhHGadYGsF6Naj8PFRgIEzjsIi/OGXoAWLE3/cglnW1pxTbO2ZWJF+8pGAqaC
|
||||
rEhokeHr2+06
|
||||
-----END NEW CERTIFICATE REQUEST-----
|
117
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/tst_certificaterequest.cpp
vendored
Normal file
117
thirdparty/qt-certificate-addon/tests/auto/certificaterequest/tst_certificaterequest.cpp
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "certificaterequest.h"
|
||||
|
||||
QT_USE_NAMESPACE_CERTIFICATE
|
||||
|
||||
class tst_CertificateRequest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void checkNull();
|
||||
void loadCrq();
|
||||
void checkEntryAttributes();
|
||||
void checkEntries();
|
||||
void checkToText();
|
||||
};
|
||||
|
||||
void tst_CertificateRequest::checkNull()
|
||||
{
|
||||
CertificateRequest csr;
|
||||
QVERIFY(csr.isNull());
|
||||
}
|
||||
|
||||
void tst_CertificateRequest::loadCrq()
|
||||
{
|
||||
QFile f("requests/test-ocsp-good-req.pem");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
CertificateRequest csr(&f);
|
||||
f.close();
|
||||
|
||||
QVERIFY(!csr.isNull());
|
||||
QVERIFY(csr.version() == 1);
|
||||
|
||||
QFile f2("requests/test-ocsp-good-req.pem");
|
||||
f2.open(QIODevice::ReadOnly);
|
||||
QByteArray filePem = f2.readAll();
|
||||
f2.close();
|
||||
|
||||
QVERIFY(filePem == csr.toPem());
|
||||
}
|
||||
|
||||
void tst_CertificateRequest::checkEntryAttributes()
|
||||
{
|
||||
QFile f("requests/test-ocsp-good-req.pem");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
CertificateRequest csr(&f);
|
||||
f.close();
|
||||
|
||||
QList<QByteArray> attrs;
|
||||
attrs << "2.5.4.3" << "2.5.4.8" << "2.5.4.6" << "1.2.840.113549.1.9.1" << "2.5.4.10";
|
||||
|
||||
QCOMPARE(attrs, csr.nameEntryAttributes());
|
||||
}
|
||||
|
||||
void tst_CertificateRequest::checkEntries()
|
||||
{
|
||||
QFile f("requests/test-ocsp-good-req.pem");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
CertificateRequest csr(&f);
|
||||
f.close();
|
||||
|
||||
QStringList commonName;
|
||||
commonName << "example.com";
|
||||
QVERIFY(commonName == csr.nameEntryInfo(Certificate::EntryCommonName));
|
||||
|
||||
QStringList organizationName;
|
||||
organizationName << "Some organisation";
|
||||
QVERIFY(organizationName == csr.nameEntryInfo(Certificate::EntryOrganizationName));
|
||||
|
||||
QStringList countryName;
|
||||
countryName << "UK";
|
||||
QVERIFY(countryName == csr.nameEntryInfo(Certificate::EntryCountryName));
|
||||
|
||||
QStringList email;
|
||||
email << "test@example.com";
|
||||
QVERIFY(email == csr.nameEntryInfo(Certificate::EntryEmail));
|
||||
|
||||
QStringList stateOrProvinceName;
|
||||
stateOrProvinceName << "Lancashire";
|
||||
QVERIFY(stateOrProvinceName == csr.nameEntryInfo(Certificate::EntryStateOrProvinceName));
|
||||
|
||||
QStringList localityName;
|
||||
QVERIFY(localityName == csr.nameEntryInfo(Certificate::EntryLocalityName));
|
||||
}
|
||||
|
||||
void tst_CertificateRequest::checkToText()
|
||||
{
|
||||
QFile f("requests/test-ocsp-good-req.pem");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
CertificateRequest csr(&f);
|
||||
f.close();
|
||||
|
||||
QLatin1String text("PKCS #10 Certificate Request Information:\n" \
|
||||
"\tVersion: 1\n" \
|
||||
"\tSubject: CN=example.com,ST=Lancashire,C=UK,EMAIL=test@example.com,O=Some organisation\n" \
|
||||
"\tSubject Public Key Algorithm: RSA\n" \
|
||||
"\t\tModulus (bits 1024):\n" \
|
||||
"\t\t\t97:c9:92:27:81:a7:4c:64:82:a2:30:d6:07:b7:57:e0\n" \
|
||||
"\t\t\t9c:ea:cd:eb:53:be:ea:b6:b5:47:66:d0:68:54:25:a7\n" \
|
||||
"\t\t\ted:21:5c:dc:fd:da:41:f6:c7:c0:35:ae:97:72:fd:8b\n" \
|
||||
"\t\t\taf:29:3d:38:5a:67:8b:39:8a:ce:86:25:0f:38:a7:b5\n" \
|
||||
"\t\t\t38:b3:8e:81:f0:ea:79:99:cb:f5:23:64:55:f3:4b:a4\n" \
|
||||
"\t\t\tb6:23:64:29:ea:ba:f3:29:52:a7:7f:32:dc:0d:b6:d9\n" \
|
||||
"\t\t\td4:e6:13:de:01:41:86:9a:2d:8f:bb:0c:18:88:09:ac\n" \
|
||||
"\t\t\td4:6a:e9:cb:8a:17:8a:85:09:a6:ae:a6:1c:05:e9:55\n" \
|
||||
"\t\tExponent:\n" \
|
||||
"\t\t\t01:00:01\n" \
|
||||
"Other Information:\n" \
|
||||
"\tPublic Key Id:\n" \
|
||||
"\t\tad19b31110ef2ef08ed382e1f4a1766bcbf9d562\n");
|
||||
|
||||
QCOMPARE(text, csr.toText());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_CertificateRequest)
|
||||
#include "tst_certificaterequest.moc"
|
1
thirdparty/qt-certificate-addon/tests/auto/certificaterequestbuilder/.gitignore
vendored
Normal file
1
thirdparty/qt-certificate-addon/tests/auto/certificaterequestbuilder/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tst_certificaterequestbuilder
|
@@ -0,0 +1,11 @@
|
||||
TEMPLATE = app
|
||||
TARGET = tst_certificaterequestbuilder
|
||||
|
||||
CONFIG += testcase
|
||||
QT += testlib network
|
||||
|
||||
LIBS += -Wl,-rpath,../../../src/certificate -L../../../src/certificate -lcertificate
|
||||
INCLUDEPATH += ../../../src/certificate
|
||||
|
||||
SOURCES += tst_certificaterequestbuilder.cpp
|
||||
|
32
thirdparty/qt-certificate-addon/tests/auto/certificaterequestbuilder/keys/leaf.key
vendored
Normal file
32
thirdparty/qt-certificate-addon/tests/auto/certificaterequestbuilder/keys/leaf.key
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIFfQIBAAKCATEA1v37hlwn7Co4FclSTACM53kt2tKXUcK6czCYdljKCMeFlm4+
|
||||
us89sETF1entTWkKQSgSnoT6xNWlueayt9pFbkFxma7tDHdFImpTkxiJ7qf3ccLX
|
||||
UY16qSMeU/vCV/Yj1uxm2XU6nXaMDfKMQGsqMslOkacls3nRhfPLrmH4kXNrueR6
|
||||
VnSSEiTvxP4h9DBhBkgOhxEi9LQQFd8nl9MaGnKAiUlRhJMFuIluu9FzzpOLEBHO
|
||||
75JFBCYmCvnfZVgLczogmzz4MS/N4V/wah1rdAuW4KeH9AOhcbncga2KmAqjY9e3
|
||||
n2o5JFhtAMrpYgNgvzLtz1sYrgY9kulm11cDXqhbC7GL+gQEIjCgDKtGHtnzBsps
|
||||
Az8UJh13HvRhGMna4w/et3/3a9+SEXXU0BdFMQIDAQABAoIBMQCwyoJ/ZmDd74nX
|
||||
QIoQPZOg9SEkBHCypzKzbo6xIypgNdJAdb/X1nuf663Tzl15fpsUIWPOPwQHwLhb
|
||||
Or5UOYVGuUI1YodD7QBI4K6BE3i5bB4qylJNmc34MAzMewbBVoL6RcP9pkzhF47s
|
||||
GTwD7RvyT1/wnkZ+Y/pL8MLZT28cDJHVd3Cyj4FeskkI8QHyz6W5iJ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bEhg5aHWe9Vc+boe6iVRCeD6CYW+bupNEOc0qJPPm9KIvBmUj6l3rD4+
|
||||
N3X5HYcJAoGYalXnKjKXEum6KzzIvm2xM5z8FHURJ8CMk6nYDKH0RWv9qPTtvoLM
|
||||
wkPu9wTii+L/9TEWpwPVGcvuFxwjgF9zulGhkDafzH+kO677AxGeukSTM0es6JIw
|
||||
V+MwMb00tjhP+NBD7QP8YXkxA+QE4loReKONz9xVarc+meYwaPf/CnMCNHH+KKqZ
|
||||
dWRkdDcn3oyRsAG3KcIt0j0=
|
||||
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,73 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "certificaterequest.h"
|
||||
#include "certificaterequestbuilder.h"
|
||||
|
||||
QT_USE_NAMESPACE_CERTIFICATE
|
||||
|
||||
class tst_CertificateRequestBuilder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void version();
|
||||
void entries();
|
||||
};
|
||||
|
||||
void tst_CertificateRequestBuilder::version()
|
||||
{
|
||||
CertificateRequestBuilder builder;
|
||||
builder.setVersion(1);
|
||||
QCOMPARE(builder.version(), 1);
|
||||
}
|
||||
|
||||
void tst_CertificateRequestBuilder::entries()
|
||||
{
|
||||
CertificateRequestBuilder builder;
|
||||
builder.setVersion(1);
|
||||
builder.addNameEntry(Certificate::EntryCountryName, "GB");
|
||||
builder.addNameEntry(Certificate::EntryOrganizationName, "Westpoint");
|
||||
builder.addNameEntry(Certificate::EntryOrganizationName, "West");
|
||||
builder.addNameEntry(Certificate::EntryOrganizationalUnitName, "My Unit");
|
||||
builder.addNameEntry(Certificate::EntryLocalityName, "My Locality");
|
||||
builder.addNameEntry(Certificate::EntryStateOrProvinceName, "My State");
|
||||
builder.addNameEntry(Certificate::EntryEmail, "test@example.com");
|
||||
builder.addNameEntry(Certificate::EntryCommonName, "www.example.com");
|
||||
|
||||
QFile f("keys/leaf.key");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QSslKey key(&f, QSsl::Rsa);
|
||||
f.close();
|
||||
|
||||
builder.setKey(key);
|
||||
CertificateRequest req = builder.signedRequest(key);
|
||||
|
||||
QStringList countryName;
|
||||
countryName << "GB";
|
||||
QCOMPARE(countryName, req.nameEntryInfo(Certificate::EntryCountryName));
|
||||
|
||||
QStringList organizationName;
|
||||
organizationName << "Westpoint";
|
||||
organizationName << "West";
|
||||
QCOMPARE(organizationName, req.nameEntryInfo(Certificate::EntryOrganizationName));
|
||||
|
||||
QStringList organizationalUnitName;
|
||||
organizationalUnitName << "My Unit";
|
||||
QCOMPARE(organizationalUnitName, req.nameEntryInfo(Certificate::EntryOrganizationalUnitName));
|
||||
|
||||
QStringList stateOrProvinceName;
|
||||
stateOrProvinceName << "My State";
|
||||
QCOMPARE(stateOrProvinceName, req.nameEntryInfo(Certificate::EntryStateOrProvinceName));
|
||||
|
||||
QStringList email;
|
||||
email << "test@example.com";
|
||||
QCOMPARE(email, req.nameEntryInfo(Certificate::EntryEmail));
|
||||
|
||||
QStringList commonName;
|
||||
commonName << "www.example.com";
|
||||
QCOMPARE(commonName, req.nameEntryInfo(Certificate::EntryCommonName));
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(tst_CertificateRequestBuilder)
|
||||
#include "tst_certificaterequestbuilder.moc"
|
1
thirdparty/qt-certificate-addon/tests/auto/keybuilder/.gitignore
vendored
Normal file
1
thirdparty/qt-certificate-addon/tests/auto/keybuilder/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tst_keybuilder
|
11
thirdparty/qt-certificate-addon/tests/auto/keybuilder/keybuilder.pro
vendored
Normal file
11
thirdparty/qt-certificate-addon/tests/auto/keybuilder/keybuilder.pro
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
TEMPLATE = app
|
||||
TARGET = tst_keybuilder
|
||||
|
||||
CONFIG += testcase
|
||||
QT += testlib network
|
||||
|
||||
LIBS += -Wl,-rpath,../../../src/certificate -L../../../src/certificate -lcertificate
|
||||
INCLUDEPATH += ../../../src/certificate
|
||||
|
||||
SOURCES += tst_keybuilder.cpp
|
||||
|
46
thirdparty/qt-certificate-addon/tests/auto/keybuilder/tst_keybuilder.cpp
vendored
Normal file
46
thirdparty/qt-certificate-addon/tests/auto/keybuilder/tst_keybuilder.cpp
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <QSslKey>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "keybuilder.h"
|
||||
|
||||
QT_USE_NAMESPACE_CERTIFICATE
|
||||
|
||||
class tst_KeyBuilder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void checkKeyLengths();
|
||||
void checkKeyChanges();
|
||||
};
|
||||
|
||||
void tst_KeyBuilder::checkKeyLengths()
|
||||
{
|
||||
QSslKey keyl = KeyBuilder::generate( QSsl::Rsa, KeyBuilder::StrengthLow );
|
||||
QVERIFY(keyl.length() >= 1248);
|
||||
|
||||
QSslKey keyn = KeyBuilder::generate( QSsl::Rsa, KeyBuilder::StrengthNormal );
|
||||
QVERIFY(keyn.length() >= 2322);
|
||||
QVERIFY(keyn.length() > keyl.length());
|
||||
|
||||
#ifdef ENABLE_SLOW_TESTS
|
||||
QSslKey keyh = KeyBuilder::generate( QSsl::Rsa, KeyBuilder::StrengthHigh );
|
||||
QVERIFY(keyh.length() >= 3248);
|
||||
QVERIFY(keyh.length() > keyn.length());
|
||||
|
||||
QSslKey keyu = KeyBuilder::generate( QSsl::Rsa, KeyBuilder::StrengthUltra );
|
||||
QVERIFY(keyu.length() >= 15424);
|
||||
QVERIFY(keyu.length() > keyh.length());
|
||||
#endif // ENABLE_SLOW_TESTS
|
||||
}
|
||||
|
||||
void tst_KeyBuilder::checkKeyChanges()
|
||||
{
|
||||
QSslKey key1 = KeyBuilder::generate( QSsl::Rsa, KeyBuilder::StrengthLow );
|
||||
QSslKey key2 = KeyBuilder::generate( QSsl::Rsa, KeyBuilder::StrengthLow );
|
||||
|
||||
QVERIFY(key1.toPem() != key2.toPem());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_KeyBuilder)
|
||||
#include "tst_keybuilder.moc"
|
Reference in New Issue
Block a user