CKM: Add invalid param ocsp tests 93/42893/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 3 Jul 2015 14:38:10 +0000 (16:38 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 3 Jul 2015 14:45:42 +0000 (16:45 +0200)
[Problem] Not enought input param tests for ocsp API.
[Solution] New tests addded.

[Verification] Run ckm-tests --regexp=ocsp_check

Change-Id: I982c3e0c47500eb332e46d1027870d487603baf7

src/ckm/async-api.cpp
src/ckm/main.cpp

index f0bb8bc..f9a8bf6 100644 (file)
@@ -57,6 +57,11 @@ const char* TEST_DATA = "dsflsdkghkslhglrtghierhgilrehgidsafasdffsgfdgdgfdgfdgfd
 const char* TEST_PASS = "test-pass";
 
 const CertificateShPtrVector EMPTY_CERT_VECTOR;
+const CertificateShPtrVector NULL_PTR_VECTOR = {
+        CertificateShPtr(),
+        CertificateShPtr(),
+        CertificateShPtr()
+};
 const AliasVector EMPTY_ALIAS_VECTOR;
 const Alias alias_PKCS_exportable = "async-test-PKCS-export";
 const Alias alias_PKCS_not_exportable = "async-test-PKCS-no-export";
@@ -1152,6 +1157,7 @@ RUNNER_TEST(TA1710_ocsp_check_invalid_param, UserEnv)
 {
     test_no_observer(&ManagerAsync::ocspCheck, EMPTY_CERT_VECTOR);
     test_invalid_param(&ManagerAsync::ocspCheck, EMPTY_CERT_VECTOR);
+    test_invalid_param(&ManagerAsync::ocspCheck, NULL_PTR_VECTOR);
 }
 
 RUNNER_TEST(TA1720_ocsp_check_negative, UserEnv)
index ca3eaa7..bb8ecfd 100644 (file)
@@ -1389,7 +1389,7 @@ RUNNER_TEST(T1313_get_chain_with_alias)
         "Wrong size of certificate chain.");
 }
 
-RUNNER_TEST(T1314_ocsp_check)
+RUNNER_TEST(T13141_ocsp_check_valid_chain)
 {
     RUNNER_IGNORED_MSG("Fixed in next version of ckm!");
 
@@ -1427,6 +1427,74 @@ RUNNER_TEST(T1314_ocsp_check)
     RUNNER_ASSERT_MSG(CKM_API_OCSP_STATUS_GOOD == status, "Verfication failed");
 }
 
+RUNNER_TEST(T13142_ocsp_check_empty)
+{
+    CKM::CertificateShPtrVector certVector;
+
+    auto manager = CKM::Manager::create();
+
+    int tmp;
+    int status;
+    RUNNER_ASSERT_MSG(
+            CKM_API_ERROR_INPUT_PARAM == (tmp = manager->ocspCheck(certVector, status)),
+        "ocspCheck should fail for empty certificate vector");
+}
+
+RUNNER_TEST(T13143_ocsp_check_empty_ptrs)
+{
+    CKM::CertificateShPtrVector certVector = {
+            CKM::CertificateShPtr(),
+            CKM::CertificateShPtr(),
+            CKM::CertificateShPtr()};
+
+    auto manager = CKM::Manager::create();
+
+    int tmp;
+    int status;
+    RUNNER_ASSERT_MSG(
+            CKM_API_ERROR_INPUT_PARAM == (tmp = manager->ocspCheck(certVector, status)),
+        "ocspCheck should fail for empty certificate vector");
+}
+
+RUNNER_TEST(T13144_ocsp_check_root)
+{
+    auto root = TestData::getTestCertificate(TestData::EQUIFAX);
+    CKM::CertificateShPtrVector certVector = {root};
+
+    auto manager = CKM::Manager::create();
+
+    RUNNER_ASSERT_MSG(NULL != root.get(), "Certificate should not be empty");
+
+    int tmp;
+    int status;
+    RUNNER_ASSERT_MSG(
+            CKM_API_ERROR_INPUT_PARAM == (tmp = manager->ocspCheck(certVector, status)),
+        "Ocsp should fail for single certificate");
+}
+
+RUNNER_TEST(T13145_ocsp_check_no_ocsp)
+{
+    auto root = TestData::getTestCertificate(TestData::EQUIFAX);
+    auto ca2 = TestData::getTestCertificate(TestData::GEOTRUST);
+    auto ca1 = TestData::getTestCertificate(TestData::GIAG2);
+
+    CKM::CertificateShPtrVector certVector = {ca1, ca2, root};
+
+    auto manager = CKM::Manager::create();
+
+    RUNNER_ASSERT_MSG(NULL != root.get(), "Certificate should not be empty");
+    RUNNER_ASSERT_MSG(NULL != ca2.get(), "Certificate should not be empty");
+    RUNNER_ASSERT_MSG(NULL != ca1.get(), "Certificate should not be empty");
+
+    int tmp;
+    int status;
+    RUNNER_ASSERT_MSG(
+        CKM_API_SUCCESS == (tmp = manager->ocspCheck(certVector, status)),
+        "Error=" << CKM::ErrorToString(tmp));
+
+    RUNNER_ASSERT_MSG(CKM_API_OCSP_STATUS_UNSUPPORTED == status, "Verfication failed");
+}
+
 RUNNER_TEST(T1315_deinit)
 {
     remove_user_data(0);