Run key-manager test on onlycap
[platform/core/test/security-tests.git] / src / ckm / capi-testcases.cpp
index 3635077..0de06f0 100644 (file)
@@ -28,7 +28,6 @@ namespace {
 const int USER_APP = 5000;
 const int GROUP_APP = 5000;
 const char* USER_PASS = "user-pass";
-const char* TEST_LABEL = "test_label";
 const char *const TEST_OBJECT1 = "OBJECT1";
 const std::string TEST_ALIAS1 = aliasWithLabel(TEST_LABEL,TEST_OBJECT1);
 const char* TEST_SYSTEM_ALIAS = "system-alias-1";
@@ -343,7 +342,7 @@ RUNNER_TEST(T30206_certificate_list_C_API)
 
 RUNNER_CHILD_TEST(T30207_user_app_save_RSA_key_C_API)
 {
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -394,7 +393,7 @@ RUNNER_CHILD_TEST(T30207_user_app_save_RSA_key_C_API)
 
 RUNNER_CHILD_TEST(T30208_user_app_save_AES_key_C_API)
 {
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -423,7 +422,7 @@ RUNNER_CHILD_TEST(T30208_user_app_save_AES_key_C_API)
 
 RUNNER_CHILD_TEST(T30209_user_app_save_AES_key_passwd_C_API)
 {
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -445,7 +444,7 @@ RUNNER_CHILD_TEST(T30209_user_app_save_AES_key_passwd_C_API)
 
 RUNNER_CHILD_TEST(T30210_app_user_save_RSA_keys_exportable_flag)
 {
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -487,7 +486,7 @@ RUNNER_CHILD_TEST(T30210_app_user_save_RSA_keys_exportable_flag)
 
 RUNNER_CHILD_TEST(T30211_app_user_save_AES_keys_exportable_flag)
 {
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -800,7 +799,7 @@ RUNNER_TEST(T3042_save_get_bin_data_C_API)
 
 RUNNER_CHILD_TEST(T3043_app_user_save_bin_data_C_API)
 {
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -933,7 +932,7 @@ RUNNER_CHILD_TEST(T3052_CAPI_create_RSA_key)
 {
        int temp;
 
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -993,7 +992,7 @@ RUNNER_CHILD_TEST(T3053_CAPI_create_DSA_key)
 {
        int temp;
 
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1178,7 +1177,6 @@ RUNNER_TEST(T3065_CAPI_deinit)
 //RUNNER_TEST_GROUP_INIT(T120_NEGATIVE_TESTS);
 
 
-
 RUNNER_TEST_GROUP_INIT(T307_CKMC_CAPI_OCSP_TESTS);
 
 RUNNER_TEST(T3071_CAPI_init)
@@ -1188,7 +1186,6 @@ RUNNER_TEST(T3071_CAPI_init)
 
 RUNNER_TEST(T3074_CAPI_ckmc_ocsp_check)
 {
-       RUNNER_IGNORED_MSG("Temporary turned off. Require network feature.");
        std::string ee = TestData::getTestCertificateBase64(TestData::MBANK);
        std::string im = TestData::getTestCertificateBase64(TestData::SYMANTEC);
 
@@ -2045,7 +2042,7 @@ RUNNER_TEST(T3095_CAPI_TYPE_load_cert_file)
 }
 
 RUNNER_TEST(T3096_CAPI_TYPE_load_p12_file) {
-       const char *p12file = "/usr/share/ckm-test/capi-t3096.p12";
+       const char *p12file = CKM_TEST_DIR "/capi-t3096.p12";
        const char *password = "password";
 
        int temp;
@@ -2097,7 +2094,7 @@ RUNNER_TEST(T3096_CAPI_TYPE_load_p12_file) {
 }
 
 RUNNER_TEST(T3097_CAPI_TYPE_load_p12_file2) {
-       const char *p12file = "/usr/share/ckm-test/capi-t3096.p12";
+       const char *p12file = CKM_TEST_DIR "/capi-t3096.p12";
        const char *password = "password";
 
        int temp;
@@ -2174,7 +2171,7 @@ RUNNER_TEST(T3102_CAPI_PKCS12_negative_wrong_password)
        ckmc_pkcs12_s *ppkcs12 = NULL;
        int temp;
        RUNNER_ASSERT_MSG(
-                       CKMC_ERROR_INVALID_FORMAT == (temp = ckmc_pkcs12_load("/usr/share/ckm-test/test1801.pkcs12", wrong_passwd, &ppkcs12)),
+                       CKMC_ERROR_INVALID_FORMAT == (temp = ckmc_pkcs12_load(CKM_TEST_DIR "/test1801.pkcs12", wrong_passwd, &ppkcs12)),
                        CKMCReadableError(temp));
 }
 
@@ -2183,7 +2180,7 @@ RUNNER_TEST(T3103_CAPI_PKCS12_add_bundle_with_chain_certs)
        ckmc_pkcs12_s *ppkcs12 = NULL;
        int temp;
        RUNNER_ASSERT_MSG(
-                       CKMC_ERROR_NONE == (temp = ckmc_pkcs12_load("/usr/share/ckm-test/pkcs.p12", NULL, &ppkcs12)),
+                       CKMC_ERROR_NONE == (temp = ckmc_pkcs12_load(CKM_TEST_DIR "/pkcs.p12", NULL, &ppkcs12)),
                        CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(NULL != ppkcs12->cert, "no certificate in PKCS12");
@@ -2376,11 +2373,7 @@ RUNNER_CHILD_TEST(T3202_CAPI_get_data_from_empty_database)
 
 RUNNER_CHILD_TEST(T3203_CAPI_lock_database)
 {
-    RUNNER_IGNORED_MSG("Temporary turned off. The default password for database must be turn off for this test.");
-    ScopedDBUnlock unlock(USER_APP, USER_PASS);
-       ScopedAccessProvider ap(TEST_LABEL);
-       ap.allowAPI("key-manager::api-storage", "rw");
-       ap.applyAndSwithToUser(USER_APP, GROUP_APP);
+       ScopedDBUnlock unlock(USER_APP, USER_PASS);
 
        int temp;
        RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
@@ -2389,7 +2382,6 @@ RUNNER_CHILD_TEST(T3203_CAPI_lock_database)
 
 RUNNER_CHILD_TEST(T3204_CAPI_get_data_from_locked_database)
 {
-    RUNNER_IGNORED_MSG("Temporary turned off. The default password for database must be turn off for this test.");
        ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
@@ -2399,17 +2391,11 @@ RUNNER_CHILD_TEST(T3204_CAPI_get_data_from_locked_database)
        char *password = NULL;
        ckmc_key_s *test_key = NULL;
 
-#ifndef PASSWORD_PROTECTION_DISABLE
        RUNNER_ASSERT_MSG(
                CKMC_ERROR_DB_LOCKED == (temp = ckmc_get_key(alias.c_str(), password, &test_key)),
                CKMCReadableError(temp));
 
        RUNNER_ASSERT_MSG(NULL == test_key, "Key value should not be changed");
-#else
-       RUNNER_ASSERT_MSG(
-               CKMC_ERROR_DB_ALIAS_UNKNOWN == (temp = ckmc_get_key(alias.c_str(), password, &test_key)),
-               CKMCReadableError(temp));
-#endif
 }
 
 RUNNER_TEST(T3204_deinit)