X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fckm%2Fcapi-testcases.cpp;h=0de06f08a61e03051f5adbe7cd2dbe9f2792903f;hb=refs%2Fchanges%2F67%2F81467%2F3;hp=fa5aa70352eda788d9e2034cd1a8551b21684315;hpb=86ba2aa7c6e01dd9193e08d01ba1c2f8bfc2d459;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git diff --git a/src/ckm/capi-testcases.cpp b/src/ckm/capi-testcases.cpp index fa5aa70..0de06f0 100644 --- a/src/ckm/capi-testcases.cpp +++ b/src/ckm/capi-testcases.cpp @@ -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); @@ -884,23 +883,21 @@ RUNNER_TEST(T3044_remove_bin_data_C_API) CKMCReadableError(temp)); } -RUNNER_TEST(T3045_save_big_data_C_API) +RUNNER_TEST(T3045_save_big_data_C_API, RemoveDataEnv) { - GarbageCollector gc; - const size_t BIG_SIZE = 5000000; // can't go much further because of stack size limit + const size_t BIG_SIZE = 5000000; ScopedAccessProvider ap(TEST_LABEL, USER_APP, GROUP_APP); - char big_data[BIG_SIZE]; + std::vector big_data(BIG_SIZE); std::ifstream is("/dev/urandom", std::ifstream::binary); if(is) - is.read(big_data, BIG_SIZE); + is.read(big_data.data(), BIG_SIZE); RUNNER_ASSERT_MSG(is, "Only " << is.gcount() << "/" << BIG_SIZE << " bytes read from /dev/urandom"); - gc.save(TEST_ALIAS1.c_str(), big_data, BIG_SIZE, CKMC_ERROR_NONE); - - check_read(TEST_OBJECT1, TEST_LABEL, big_data, BIG_SIZE, CKMC_ERROR_NONE); + save_data(TEST_ALIAS1.c_str(), big_data.data(), BIG_SIZE, CKMC_ERROR_NONE); + check_read(TEST_OBJECT1, TEST_LABEL, big_data.data(), BIG_SIZE, CKMC_ERROR_NONE); } RUNNER_TEST(T3050_deinit_C_API) @@ -935,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); @@ -995,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); @@ -1180,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) @@ -1190,8 +1186,7 @@ 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 ee = TestData::getTestCertificateBase64(TestData::MBANK); std::string im = TestData::getTestCertificateBase64(TestData::SYMANTEC); ckmc_cert_s c_cert; @@ -2047,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; @@ -2099,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; @@ -2176,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)); } @@ -2185,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"); @@ -2378,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)), @@ -2391,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);