security-manager-tests: Add tests for SharedRO path registration 32/69332/3
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 12 May 2016 15:00:27 +0000 (17:00 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 12 May 2016 15:27:41 +0000 (17:27 +0200)
Add tests verifying proper request handling and labeling of
SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO path.

Verification: run security-manager-tests --regexp=path_req_shared_ro

Change-Id: I3a5e0594ad37a87271d51d72ecca6e4de7c2fd84

src/security-manager-tests/security_manager_tests.cpp

index 7c5f4e0..dc0ccb5 100644 (file)
@@ -4314,7 +4314,6 @@ RUNNER_TEST(security_manager_66_path_req_check_labels)
     std::string SM_RW_PATH = genRWPath(66);
     std::string SM_RO_PATH = genROPath(66);
     std::string SM_PUBLIC_RO_PATH = genPublicROPath(66);
-    // TODO others, trusted rw
 
     prepare_app_env(66);
 
@@ -4330,6 +4329,69 @@ RUNNER_TEST(security_manager_66_path_req_check_labels)
     uninstall_app(sm_app_id, sm_pkg_id, true);
 }
 
+RUNNER_TEST(security_manager_67_path_req_shared_ro_3_0)
+{
+    const char *const sm_app_id = "sm_test_67_app_id";
+    const char *const sm_pkg_id = "sm_test_67_pkg_id";
+
+    TemporaryTestUser user("sm_test_67_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    InstallRequest ireq;
+    ireq.setAppId(sm_app_id);
+    ireq.setPkgId(sm_pkg_id);
+    ireq.setUid(user.getUid());
+    ireq.setAppTizenVersion("3.0");
+    Api::install(ireq);
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
+
+    Api::registerPaths(preq, (lib_retcode)SECURITY_MANAGER_ERROR_INPUT_PARAM);
+}
+
+RUNNER_TEST(security_manager_68_path_req_shared_ro_2_X)
+{
+    const char *const sm_app_id = "sm_test_68_app_id";
+    const char *const sm_pkg_id = "sm_test_68_pkg_id";
+
+    TemporaryTestUser user("sm_test_68_user_name", GUM_USERTYPE_NORMAL, false);
+    user.create();
+    std::string path = appDirPath(user, sm_app_id, sm_pkg_id);
+
+    removeTestDirs(user, sm_app_id, sm_pkg_id);
+    createTestDirs(user, sm_app_id, sm_pkg_id);
+
+    InstallRequest ireq;
+    ireq.setAppId(sm_app_id);
+    ireq.setPkgId(sm_pkg_id);
+    ireq.setUid(user.getUid());
+    ireq.setAppTizenVersion("2.4");
+    Api::install(ireq);
+
+    PathsRequest preq;
+    preq.setPkgId(sm_pkg_id);
+    preq.setUid(user.getUid());
+    preq.addPath(path, SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO);
+
+    Api::registerPaths(preq);
+
+    // check labels
+    nftw_expected_label = generatePkgLabel(sm_pkg_id) + "::SharedRO";
+    nftw_expected_transmute = true;
+    nftw_expected_exec = false;
+    int result = nftw(path.c_str(), &nftw_check_sm_labels, FTW_MAX_FDS, FTW_PHYS);
+    RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for " << path);
+}
+
+// TODO trusted rw
+
 int main(int argc, char *argv[])
 {
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);