}
};
+CKM::Alias alias_PKCS_exportable = "async-test-PKCS-export";
+CKM::Alias alias_PKCS_not_exportable = "async-test-PKCS-no-export";
+
+CKM::PKCS12ShPtr loadPkcs()
+{
+ std::ifstream is("/usr/share/ckm-test/pkcs.p12");
+ std::istreambuf_iterator<char> begin(is), end;
+ std::vector<char> buff(begin, end);
+
+ CKM::RawBuffer buffer(buff.size());
+ memcpy(buffer.data(), buff.data(), buff.size());
+
+ auto pkcs = CKM::PKCS12::create(buffer, CKM::Password());
+ RUNNER_ASSERT_MSG(
+ NULL != pkcs.get(),
+ "Error in PKCS12::create()");
+
+ auto cert = pkcs->getCertificate();
+ RUNNER_ASSERT_MSG(
+ NULL != cert.get(),
+ "Error in PKCS12::getCertificate()");
+
+ auto key = pkcs->getKey();
+ RUNNER_ASSERT_MSG(
+ NULL != key.get(),
+ "Error in PKCS12::getKey()");
+
+ auto caVector = pkcs->getCaCertificateShPtrVector();
+ RUNNER_ASSERT_MSG(
+ 2 == caVector.size(),
+ "Wrong size of vector");
+
+ return pkcs;
+}
+
} // namespace anonymous
}
}
-namespace
-{
-CKM::Alias alias_PKCS_exportable = "async-test-PKCS-export";
-CKM::Alias alias_PKCS_not_exportable = "async-test-PKCS-no-export";
-}
-
RUNNER_TEST(TA2000_PKCS_add_bundle_with_chain_certs, CKMAsyncAPIEnv)
{
DBCleanup dbc;
- auto manager = CKM::Manager::create();
- std::ifstream is("/usr/share/ckm-test/pkcs.p12");
- std::istreambuf_iterator<char> begin(is), end;
- std::vector<char> buff(begin, end);
-
- CKM::RawBuffer buffer(buff.size());
- memcpy(buffer.data(), buff.data(), buff.size());
-
- auto pkcs = CKM::PKCS12::create(buffer, CKM::Password());
- RUNNER_ASSERT_MSG(
- NULL != pkcs.get(),
- "Error in PKCS12::create()");
-
- auto cert = pkcs->getCertificate();
- RUNNER_ASSERT_MSG(
- NULL != cert.get(),
- "Error in PKCS12::getCertificate()");
-
- auto key = pkcs->getKey();
- RUNNER_ASSERT_MSG(
- NULL != key.get(),
- "Error in PKCS12::getKey()");
-
- auto caVector = pkcs->getCaCertificateShPtrVector();
- RUNNER_ASSERT_MSG(
- 2 == caVector.size(),
- "Wrong size of vector");
+ auto pkcs = loadPkcs();
// save to the CKM
CKM::Policy exportable;
CKM::Policy notExportable(CKM::Password(), false);
test_positive(&ManagerAsync::savePKCS12,
- alias_PKCS_exportable,
+ dbc.alias(alias_PKCS_exportable.c_str()),
pkcs,
exportable,
exportable);
test_negative(&ManagerAsync::savePKCS12,
CKM_API_ERROR_DB_ALIAS_EXISTS,
- alias_PKCS_exportable,
+ dbc.alias(alias_PKCS_exportable.c_str()),
pkcs,
exportable,
exportable);
test_positive(&ManagerAsync::savePKCS12,
- alias_PKCS_not_exportable,
+ dbc.alias(alias_PKCS_not_exportable.c_str()),
pkcs,
notExportable,
notExportable);
test_negative(&ManagerAsync::savePKCS12,
CKM_API_ERROR_DB_ALIAS_EXISTS,
- alias_PKCS_not_exportable,
+ dbc.alias(alias_PKCS_not_exportable.c_str()),
pkcs,
notExportable,
notExportable);
RUNNER_TEST(TA2010_PKCS_get, CKMAsyncAPIEnv)
{
DBCleanup dbc;
- auto manager = CKM::Manager::create();
+
+ auto pkcs = loadPkcs();
+
+ // save to the CKM
+ CKM::Policy exportable;
+ CKM::Policy notExportable(CKM::Password(), false);
+
+ test_positive(&ManagerAsync::savePKCS12,
+ dbc.alias(alias_PKCS_exportable.c_str()),
+ pkcs,
+ exportable,
+ exportable);
+ test_positive(&ManagerAsync::savePKCS12,
+ dbc.alias(alias_PKCS_not_exportable.c_str()),
+ pkcs,
+ notExportable,
+ notExportable);
// fail - no entry
test_negative(&ManagerAsync::getPKCS12,