-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the transport of internal name and comment during export/import of templates.
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
|
||
#include "lib/pki_multi.h" | ||
#include "lib/db_x509.h" | ||
#include "lib/db_temp.h" | ||
#include "lib/pki_x509.h" | ||
#include "lib/pki_temp.h" | ||
#include "lib/xfile.h" | ||
#include "lib/database_model.h" | ||
|
||
|
@@ -96,6 +98,21 @@ void verify_file(const QString &name, QList<unsigned> hashes) | |
verify_key(name, hashes, false); | ||
} | ||
|
||
void verify_template(const QString &name) | ||
{ | ||
pki_multi *pems = new pki_multi(); | ||
pems->probeAnything(name); | ||
QList<pki_base *> temps = pems->pull(); | ||
QCOMPARE(temps.size(), 1); | ||
pki_temp *temp = dynamic_cast<pki_temp*>(temps[0]); | ||
QVERIFY(temp != nullptr); | ||
QCOMPARE(temp->getIntName(), "My Template Internal Name"); | ||
QCOMPARE(temp->getComment(), "My XCA TEMPLATE comment"); | ||
x509name xn = temp->getSubject(); | ||
QCOMPARE(xn.getEntryByNid(NID_commonName), "CA Template"); | ||
QCOMPARE(xn.getEntryByNid(NID_pkcs9_emailAddress), "[email protected]"); | ||
} | ||
|
||
void export_by_id(int id, const QString &name, | ||
QModelIndexList &list, db_base *db) | ||
{ | ||
|
@@ -135,7 +152,8 @@ void test_main::exportFormat() | |
pemdata["Inter CA 1 Key"] + | ||
pemdata["Root CA"] + | ||
pemdata["Endentity"] + | ||
pemdata["CA CRL Test"]; | ||
pemdata["CA CRL Test"] + | ||
pemdata["XCA Template"]; | ||
|
||
pem->fromPEMbyteArray(all.toUtf8(), QString()); | ||
QCOMPARE(pem->failed_files.count(), 0); | ||
|
@@ -372,6 +390,20 @@ void test_main::exportFormat() | |
verify_key(file, QList<unsigned> { ED25519_HASH }, true); | ||
check_pems(file, 1, QStringList{ "BEGIN ENCRYPTED PRIVATE KEY" }); | ||
|
||
// Export XCA Template and verify the internal name and comment | ||
file = AUTOFILE(XCA_TEMPLATE) | ||
db_base *temps = Database.model<db_temp>(); | ||
list.clear(); | ||
pki_base *temp = temps->getByName("CA Template"); // The common name | ||
Q_ASSERT(temp != nullptr); | ||
Q_ASSERT(temp->getComment().isEmpty()); | ||
temp->setComment("My XCA TEMPLATE comment"); | ||
temp->setIntName("My Template Internal Name"); | ||
list << temps->index(temp); | ||
export_by_id(35, file, list, temps); | ||
verify_template(file); | ||
check_pems(file, 1, QStringList{ "BEGIN XCA TEMPLATE" }); | ||
|
||
} catch (...) { | ||
QString m = QString("Exception thrown L %1").arg(l); | ||
QVERIFY2(false, m.toUtf8().constData()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters