From: Bartlomiej Grzelewski Date: Tue, 8 Sep 2015 16:01:16 +0000 (+0200) Subject: CKM: Fix T120 group of tests. X-Git-Tag: security-manager_5.5_testing~9^2~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9bc56c7323a6aa6ad79355b7c6fdb7564e41ffec;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git CKM: Fix T120 group of tests. Change-Id: I8ddf507da7c40e786c9b657b09bf2166ebb930d8 --- diff --git a/src/ckm/capi-testcases.cpp b/src/ckm/capi-testcases.cpp index 4509cb4e..1615170c 100644 --- a/src/ckm/capi-testcases.cpp +++ b/src/ckm/capi-testcases.cpp @@ -2358,10 +2358,10 @@ RUNNER_TEST(T3201_CAPI_unlock_database) RUNNER_CHILD_TEST(T3202_CAPI_get_data_from_empty_database) { + 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; CKM::Alias alias = "mykey"; @@ -2377,10 +2377,10 @@ RUNNER_CHILD_TEST(T3202_CAPI_get_data_from_empty_database) RUNNER_CHILD_TEST(T3203_CAPI_lock_database) { + 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)), diff --git a/src/ckm/initial-values.cpp b/src/ckm/initial-values.cpp index 535694a4..9d6f179a 100644 --- a/src/ckm/initial-values.cpp +++ b/src/ckm/initial-values.cpp @@ -153,10 +153,10 @@ RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP) // [test2] { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap(TEST_WEB_APP_1); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); check_key(XML_1_EXPECTED_KEY_1_RSA.c_str(), CKMC_ERROR_NOT_EXPORTABLE); check_key_not_visible(XML_1_EXPECTED_KEY_2_RSA.c_str()); @@ -167,10 +167,10 @@ RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP) // [test3] { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap(TEST_WEB_APP_2); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); check_key_not_visible(XML_1_EXPECTED_KEY_1_RSA.c_str()); check_key_allowed(XML_1_EXPECTED_KEY_2_RSA.c_str(), CKMC_KEY_RSA_PRIVATE); diff --git a/src/ckm/main.cpp b/src/ckm/main.cpp index 46313b1f..5549a936 100644 --- a/src/ckm/main.cpp +++ b/src/ckm/main.cpp @@ -506,10 +506,10 @@ RUNNER_TEST(T1031_save_get_bin_data) RUNNER_CHILD_TEST(T1032_app_user_save_bin_data) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int temp; auto manager = CKM::Manager::create(); @@ -580,10 +580,10 @@ RUNNER_TEST(T1033_remove_bin_data) RUNNER_TEST(T1034_app_remove_bin_data) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int temp; auto manager = CKM::Manager::create(); @@ -823,10 +823,10 @@ RUNNER_TEST(T12100_init) RUNNER_TEST(T12101_key_exist) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int ret; auto manager = CKM::Manager::create(); @@ -859,10 +859,10 @@ RUNNER_TEST(T12101_key_exist) RUNNER_TEST(T12102_saveKey_empty_alias) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); std::string keyPem = "-----BEGIN PUBLIC KEY-----\n" "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n" @@ -888,10 +888,10 @@ RUNNER_TEST(T12102_saveKey_empty_alias) RUNNER_TEST(T12103_saveKey_foreign_label) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); std::string keyPem = "-----BEGIN PUBLIC KEY-----\n" "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2b1bXDa+S8/MGWnMkru4\n" @@ -916,10 +916,10 @@ RUNNER_TEST(T12103_saveKey_foreign_label) RUNNER_TEST(T12104_saveKey_empty_key) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); CKM::KeyShPtr key; //key is not initialized CKM::Alias alias = "empty-key"; @@ -933,10 +933,10 @@ RUNNER_TEST(T12104_saveKey_empty_key) RUNNER_TEST(T12105_saveCertificate_empty_alias) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); auto cert = TestData::getTestCertificate(TestData::GIAG2); CKM::Alias alias; //alias is not initialized @@ -950,10 +950,10 @@ RUNNER_TEST(T12105_saveCertificate_empty_alias) RUNNER_TEST(T12106_saveCertificate_foreign_label) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); auto cert = TestData::getTestCertificate(TestData::GIAG2); CKM::Alias alias = "iamsomebodyelse alias"; @@ -967,10 +967,10 @@ RUNNER_TEST(T12106_saveCertificate_foreign_label) RUNNER_TEST(T12107_saveCertificate_empty_cert) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); CKM::CertificateShPtr cert; //cert is not initialized CKM::Alias alias = "empty-cert"; @@ -984,10 +984,10 @@ RUNNER_TEST(T12107_saveCertificate_empty_cert) RUNNER_TEST(T12108_saveData_empty_alias) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); std::string testData = "test data test data test data"; CKM::RawBuffer buffer(testData.begin(), testData.end()); @@ -1002,10 +1002,10 @@ RUNNER_TEST(T12108_saveData_empty_alias) RUNNER_TEST(T12109_saveData_foreign_label) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); std::string testData = "test data test data test data"; CKM::RawBuffer buffer(testData.begin(), testData.end()); @@ -1020,10 +1020,10 @@ RUNNER_TEST(T12109_saveData_foreign_label) RUNNER_TEST(T12110_saveData_empty_data) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); CKM::RawBuffer buffer; CKM::Alias alias = "empty-data"; @@ -1041,10 +1041,10 @@ RUNNER_TEST(T12110_saveData_empty_data) RUNNER_TEST(T12111_getKey_alias_not_exist) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); CKM::KeyShPtr key; CKM::Alias alias = "this-alias-not-exist"; @@ -1058,10 +1058,10 @@ RUNNER_TEST(T12111_getKey_alias_not_exist) RUNNER_TEST(T12112_getCertificate_alias_not_exist) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); CKM::CertificateShPtr certificate; CKM::Alias alias = "this-alias-not-exist"; @@ -1075,10 +1075,10 @@ RUNNER_TEST(T12112_getCertificate_alias_not_exist) RUNNER_TEST(T12113_getData_alias_not_exist) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int temp; auto manager = CKM::Manager::create(); @@ -1094,10 +1094,10 @@ RUNNER_TEST(T12113_getData_alias_not_exist) */ RUNNER_TEST(T12114_RSA_key_damaged) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int ret; auto manager = CKM::Manager::create(); @@ -1126,10 +1126,10 @@ RUNNER_TEST(T12114_RSA_key_damaged) RUNNER_TEST(T12115_RSA_key_too_short) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int ret; auto manager = CKM::Manager::create(); @@ -1155,10 +1155,10 @@ RUNNER_TEST(T12115_RSA_key_too_short) RUNNER_TEST(T12116_DSA_key_too_short) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int ret; auto manager = CKM::Manager::create(); @@ -1207,10 +1207,10 @@ RUNNER_TEST(T12117_AES_key_too_short) RUNNER_TEST(T12118_RSA_key_damaged_serviceTest) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); int ret; auto manager = CKM::Manager::create(); @@ -1254,10 +1254,10 @@ RUNNER_TEST(T12118_RSA_key_damaged_serviceTest) RUNNER_TEST(T12119_saveCertificate_damaged_serviceTest) { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap("mylabel"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); // fake the client - let the service detect the problem class WrongCertImpl : public CKM::Certificate @@ -2482,10 +2482,10 @@ RUNNER_TEST(T1511_insert_data) CKM::Alias certeeAlias("CertEE"); CKM::Alias certimAlias("CertIM"); { + ScopedDBUnlock unlock(USER_TEST, APP_PASS); ScopedAccessProvider ap("my-label"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_TEST, GROUP_APP); - ScopedDBUnlock unlock(USER_TEST, APP_PASS); auto manager = CKM::Manager::create(); RUNNER_ASSERT(CKM_API_SUCCESS == manager->saveCertificate(certeeAlias, certee, CKM::Policy())); @@ -2498,10 +2498,10 @@ RUNNER_TEST(T1511_insert_data) // actual test { + ScopedDBUnlock unlock(USER_TEST, APP_PASS); ScopedAccessProvider ap("my-label"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_TEST, GROUP_APP); - ScopedDBUnlock unlock(USER_TEST, APP_PASS); auto manager = CKM::Manager::create(); int status1 = manager->saveCertificate(certeeAlias, certee, CKM::Policy()); @@ -2524,11 +2524,11 @@ RUNNER_TEST_GROUP_INIT(T170_CKM_STORAGE_PERNAMENT_TESTS); RUNNER_TEST(T1701_init_unlock_key) { + unlock_user_data(USER_TEST+1, "t170-special-password"); + ScopedAccessProvider ap("t170-special-label"); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_TEST+1, GROUP_APP); - - unlock_user_data(USER_TEST+1, "t170-special-password"); } RUNNER_CHILD_TEST(T1702_insert_data) @@ -3331,10 +3331,10 @@ RUNNER_TEST(T1901_init_unlock_key) RUNNER_TEST(T1902_get_data) { + ScopedDBUnlock unlock(USER_APP, T190_PASSWD); ScopedAccessProvider ap(TEST_LABEL); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, T190_PASSWD); auto manager = CKM::Manager::create(); CKM::KeyShPtr ptr; diff --git a/src/ckm/system-db.cpp b/src/ckm/system-db.cpp index 6f33363b..5a0f7ef5 100644 --- a/src/ckm/system-db.cpp +++ b/src/ckm/system-db.cpp @@ -267,10 +267,10 @@ RUNNER_TEST(T5035_CLIENT_APP_TRY_REMOVING_SYSTEM_ITEM) // [test] { + ScopedDBUnlock unlock(USER_APP, APP_PASS); ScopedAccessProvider ap(TEST_LABEL); ap.allowAPI("key-manager::api-storage", "rw"); ap.applyAndSwithToUser(USER_APP, GROUP_APP); - ScopedDBUnlock unlock(USER_APP, APP_PASS); check_remove_denied(TEST_SYSTEM_ALIAS.c_str()); }