security-manager: use Smack label for verifying Cynara rules, not pkgId 59/27459/5
authorRafal Krypa <r.krypa@samsung.com>
Fri, 12 Sep 2014 15:10:27 +0000 (17:10 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 22 Sep 2014 17:16:15 +0000 (10:16 -0700)
Since security-manager doesn't provide function for that, tests
need to reimplement it. It should be kept in line with security-manager
code. For now there is only one label for all apps: "User".

Change-Id: I79eafea8c38bb86a3ec775a851d7e7605c1865e8
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
tests/security-manager-tests/security_manager_tests.cpp

index eac5194e10de4dafe7f5caf555706db55ebba3a7..476acef5f1a3660aea07049502ef0cd4fc57e249 100644 (file)
@@ -52,6 +52,11 @@ static const char *const SM_DENIED_PATH = "/etc/smack/test_DIR/non_app_dir";
 static const char *const SM_PRIVATE_PATH_FOR_USER_5000 = "/home/app/securitytests/test_DIR";
 static const char *const ANY_USER_REPRESENTATION = "anyuser";/*this may be actually any string*/
 
+static void generateAppLabel(const std::string &pkgId, std::string &label)
+{
+    (void) pkgId;
+    label = "User";
+}
 
 
 static bool isLinkToExec(const char *fpath, const struct stat *sb)
@@ -215,15 +220,17 @@ static void check_app_permissions(const char *const app_id, const char *const pk
                                   const privileges_t &allowed_privs, const privileges_t &denied_privs)
 {
     (void) app_id;
+    std::string smackLabel;
+    generateAppLabel(pkg_id, smackLabel);
 
     CynaraTestClient ctc;
 
     for (auto &priv : allowed_privs) {
-        ctc.check(pkg_id, "", user, priv.c_str(), CYNARA_API_SUCCESS);
+        ctc.check(smackLabel.c_str(), "", user, priv.c_str(), CYNARA_API_SUCCESS);
     }
 
     for (auto &priv : denied_privs) {
-        ctc.check(pkg_id, "", user, priv.c_str(), CYNARA_API_ACCESS_DENIED);
+        ctc.check(smackLabel.c_str(), "", user, priv.c_str(), CYNARA_API_ACCESS_DENIED);
     }
 }