security-manager: fix tests related to privacy privileges
[platform/core/test/security-tests.git] / src / security-manager-tests / test_cases_privacy_manager.cpp
index d40e864..eeec39a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016-2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
 #include <cynara_test_admin.h>
 #include <dpl/test/test_runner.h>
 #include <dpl/test/test_runner_child.h>
+#include <pkg_privacy_privileges.h>
 #include <policy_configuration.h>
 #include <scoped_installer.h>
 #include <sm_api.h>
@@ -78,18 +79,18 @@ const std::vector<Privileges> TEST_PRIVILEGES = {
     }
 };
 
-const std::vector<Privileges> TEST_PRIVACY_PRIVILEGES = {
+const PrivilegeVector TEST_PRIVACY_PRIVILEGES[] = {
     {
-        "http://tizen.org/privilege/telephony",
-        "http://tizen.org/privilege/led",
-        "http://tizen.org/privilege/callhistory.read", // privacy-related privileges start here
-        "http://tizen.org/privilege/account.read",
-        "http://tizen.org/privilege/healthinfo"
+        Privilege("http://tizen.org/privilege/telephony"),
+        Privilege("http://tizen.org/privilege/led"),
+        Privilege("http://tizen.org/privilege/callhistory.read", Privilege::PRIVACY),
+        Privilege("http://tizen.org/privilege/account.read", Privilege::PRIVACY),
+        Privilege("http://tizen.org/privilege/healthinfo", Privilege::PRIVACY),
     },
     {
-        "http://tizen.org/privilege/telephony",
-        "http://tizen.org/privilege/led",
-        "http://tizen.org/privilege/callhistory.read" // privacy-related privileges start here
+        Privilege("http://tizen.org/privilege/telephony"),
+        Privilege("http://tizen.org/privilege/led"),
+        Privilege("http://tizen.org/privilege/callhistory.read", Privilege::PRIVACY),
     }
 };
 
@@ -836,6 +837,7 @@ RUNNER_CHILD_TEST(security_manager_18_privacy_manager_privacy_related_privileges
     PolicyEntry filter (app.getAppId(), user.getUidString(), SECURITY_MANAGER_ANY);
     std::vector<PolicyEntry> policyEntries;
     {
+        PkgPrivacyPrivileges setupPrivacyPrivs(app);
         ScopedInstaller installer(app);
         unsigned int privacyNum = countPrivacyPrivileges(app.getPrivileges());
 
@@ -878,12 +880,14 @@ void test_privacy_related_privileges(bool isHybrid) {
     if (isHybrid)
         app1.setHybrid();
     app1.addPrivileges(TEST_PRIVACY_PRIVILEGES[0]);
+    PkgPrivacyPrivileges setupPrivacyPrivs1(app1);
     ScopedInstaller installer1(app1);
 
     AppInstallHelper app2("sm_test_19_app_id_2", pkgId, user.getUid());
     if (isHybrid)
         app2.setHybrid();
     app2.addPrivileges(TEST_PRIVACY_PRIVILEGES[1]);
+    PkgPrivacyPrivileges setupPrivacyPrivs2(app2);
     ScopedInstaller installer2(app2);
 
     int privacyCount1, privacyCount2;
@@ -941,6 +945,7 @@ RUNNER_CHILD_TEST(security_manager_20_privacy_manager_privacy_related_privileges
     AppInstallHelper app("sm_test_20", user.getUid());
     app.addPrivileges(TEST_PRIVACY_PRIVILEGES[0]);
 
+    PkgPrivacyPrivileges setupPrivacyPrivs(app);
     ScopedInstaller installer(app);
 
     CynaraTestAdmin::Admin admin;