Add test for libprivilege-control / perm_add_additional_rules.
[platform/core/test/security-tests.git] / tests / libprivilege-control-tests / test_cases.cpp
index f738e77..874dbd8 100644 (file)
 #include <dpl/log/log.h>
 #include <tests_common.h>
 #include <libprivilege-control_test_common.h>
-#include <tracker.h>
+#include "common/duplicates.h"
 #include "common/db.h"
 
-#include <iostream>
-
 #define SMACK_STARTUP_RULES_FILE "/opt/etc/smack-app-early/accesses.d/rules"
 
 #define EARLY_RULE_SUBJECT    "livebox.web-provider"
@@ -586,7 +584,7 @@ RUNNER_TEST(privilege_control11_add_api_feature)
     result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, NULL, 0);
     RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
-    const char *test6[] = { "-malformed malformed rwxat" };
+    const char *test6[] = { "-malformed malformed rwxat", NULL };
     result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, NULL, 0);
     RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
@@ -614,7 +612,7 @@ RUNNER_TEST(privilege_control11_add_api_feature)
     result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, NULL, 0);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", NULL}; // TODO This fails.
+    const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", NULL }; // TODO This fails.
     result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, NULL, 0);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
@@ -630,7 +628,7 @@ RUNNER_TEST(privilege_control11_add_api_feature)
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
     // empty group ids
-    const char *test13[] = { "~APP~ b a",NULL };
+    const char *test13[] = { "~APP~ b a", NULL};
     result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[12].c_str(), test13,(const gid_t[]) {0,1,2},0);
     RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
     result = file_exists(OSP_BLAHBLAH_DAC[12].c_str());
@@ -693,7 +691,7 @@ RUNNER_TEST(privilege_control07_app_uninstall)
     DB_END
 
     TestLibPrivilegeControlDatabase db_test;
-    db_test.test_db_after__perm_app_uninstall(TRACE_FROM_HERE, APP_ID);
+    db_test.test_db_after__perm_app_uninstall(APP_ID);
 }
 
 /*
@@ -1452,6 +1450,8 @@ RUNNER_TEST_SMACK(privilege_control20_app_setup_path_npruntime)
     std::string nptargetlabel = std::string(APP_NPRUNTIME) + ".npruntime";
     char *label = NULL;
 
+    restore_original_additional_rules();
+
     DB_BEGIN
 
     result = perm_app_uninstall(APP_NPRUNTIME);
@@ -1521,8 +1521,8 @@ RUNNER_TEST(privilege_control21_early_rules)
     DB_END
 
     TestLibPrivilegeControlDatabase db_test;
-    db_test.test_db_after__perm_app_install(TRACE_FROM_HERE, APP_ID);
-    db_test.test_db_after__perm_app_install(TRACE_FROM_HERE, APP_TEST_APP_1);
+    db_test.test_db_after__perm_app_install(APP_ID);
+    db_test.test_db_after__perm_app_install(APP_TEST_APP_1);
 
     DB_BEGIN