Add security-manager database records testing. 39/23839/2
authorMarcin Lis <m.lis@samsung.com>
Thu, 3 Jul 2014 13:47:09 +0000 (15:47 +0200)
committerMarcin Lis <m.lis@samsung.com>
Mon, 7 Jul 2014 09:07:42 +0000 (11:07 +0200)
Use the TestSecurityManagerDatabase class to test installation and privilege
assignment process in security-manager's database.

Change-Id: I08155d56904c31fe2a124d86d089014e9da95008
Signed-off-by: Marcin Lis <m.lis@samsung.com>
tests/security-manager-tests/security_manager_tests.cpp

index 1c677ba..b33e468 100644 (file)
@@ -260,11 +260,36 @@ static void check_app_after_install(const char *const app_id, const char *const
                                     const privileges_t &allowed_privs, const privileges_t &denied_privs,
                                     const rules_t &allowed_rules, const rules_t &denied_rules)
 {
+    TestSecurityManagerDatabase dbtest;
+    dbtest.test_db_after__app_install(app_id, pkg_id, allowed_privs);
+    dbtest.check_privileges_removed(app_id, pkg_id, denied_privs);
+
     check_app_permissions(app_id, pkg_id,
                           allowed_privs, denied_privs,
                           allowed_rules, denied_rules);
 }
 
+static void check_app_after_install(const char *const app_id, const char *const pkg_id)
+{
+    TestSecurityManagerDatabase dbtest;
+    dbtest.test_db_after__app_install(app_id, pkg_id);
+}
+
+static void check_app_after_uninstall(const char *const app_id, const char *const pkg_id,
+                                      const privileges_t &privileges, const bool is_pkg_removed)
+{
+    TestSecurityManagerDatabase dbtest;
+    dbtest.test_db_after__app_uninstall(app_id, pkg_id, privileges, is_pkg_removed);
+}
+
+static void check_app_after_uninstall(const char *const app_id, const char *const pkg_id,
+                                      const bool is_pkg_removed)
+{
+    TestSecurityManagerDatabase dbtest;
+    dbtest.test_db_after__app_uninstall(app_id, pkg_id, is_pkg_removed);
+}
+
+
 RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER)
 
 
@@ -291,6 +316,9 @@ RUNNER_TEST(security_manager_01_app_double_install_double_uninstall)
     RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
             "installing already installed app failed. Result: " << result);
 
+    /* Check records in the security-manager database */
+    check_app_after_install(SM_APP_ID1, SM_PKG_ID1);
+
     request.reset(do_app_inst_req_new());
 
     result = security_manager_app_inst_req_set_app_id(request.get(), SM_APP_ID1);
@@ -304,6 +332,9 @@ RUNNER_TEST(security_manager_01_app_double_install_double_uninstall)
     result = security_manager_app_uninstall(request.get());
     RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
             "uninstalling already uninstalled app failed. Result: " << result);
+
+    /* Check records in the security-manager database */
+    check_app_after_uninstall(SM_APP_ID1, SM_PKG_ID1, TestSecurityManagerDatabase::REMOVED);
 }
 
 RUNNER_TEST(security_manager_02_app_install_uninstall_full)
@@ -349,6 +380,7 @@ RUNNER_TEST(security_manager_02_app_install_uninstall_full)
     RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
             "installing app failed. Result: " << result);
 
+    /* Check records in the security-manager database */
     check_app_after_install(SM_APP_ID2, SM_PKG_ID2,
                             SM_ALLOWED_PRIVILEGES, SM_DENIED_PRIVILEGES,
                             SM_ALLOWED_RULES, SM_DENIED_RULES);
@@ -366,6 +398,10 @@ RUNNER_TEST(security_manager_02_app_install_uninstall_full)
     RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
             "uninstalling app failed. Result: " << result);
 
+    /* Check records in the security-manager database,
+     * all previously allowed privileges should be removed */
+    check_app_after_uninstall(SM_APP_ID2, SM_PKG_ID2,
+                              SM_ALLOWED_PRIVILEGES, TestSecurityManagerDatabase::REMOVED);
 }
 
 int main(int argc, char *argv[])