CKM: Add test for PKCS12 api.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Tue, 3 Feb 2015 16:31:56 +0000 (17:31 +0100)
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>
Wed, 18 Feb 2015 09:46:59 +0000 (10:46 +0100)
Change-Id: I931405c6315053424425bec6ebfbe6e3de01d683

tests/ckm/main.cpp

index 4241c25ceec981796f71457d25c25e9ec072ea34..3a9f380834f208108373de1d29e900c7d55ed557 100644 (file)
@@ -3573,7 +3573,36 @@ RUNNER_TEST(T1811_remove_bundle_with_chain_certificates)
         "Error=" << CKM::ErrorToString(tmp));
 }
 
-RUNNER_TEST(T1812_deinit)
+RUNNER_TEST(T1812_negative_get_pkcs12_wrong_password)
+{
+    CKM::Alias alias = "t1812alias1";
+
+    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::PKCS12ShPtr pkcs12;
+
+    CKM::RawBuffer buffer(buff.size());
+    memcpy(buffer.data(), buff.data(), buff.size());
+
+    auto pkcs = CKM::PKCS12::create(buffer, CKM::Password());
+    RUNNER_ASSERT_MSG_BT(
+        NULL != pkcs.get(),
+        "Error in PKCS12::create()");
+
+    int temp;
+    RUNNER_ASSERT_MSG_BT(
+        CKM_API_SUCCESS == (temp = manager->savePKCS12(alias, pkcs, CKM::Policy("easypass"), CKM::Policy("easypass"))),
+        "Error=" << CKM::ErrorToString(temp));
+
+    RUNNER_ASSERT_MSG_BT(
+        CKM_API_ERROR_AUTHENTICATION_FAILED == (temp = manager->getPKCS12(alias, pkcs)),
+        "Error=" << CKM::ErrorToString(temp));
+}
+
+RUNNER_TEST(T1813_deinit)
 {
     int temp;
     auto control = CKM::Control::create();