free(license);
license = nullptr;
}
+
+RUNNER_CHILD_TEST(app_defined_08_add_get_client_license)
+{
+ int result;
+ char *license = nullptr;
+ const std::string privilegeA = "http://tizen.org/applicationDefinedPrivilege/app_defined_08a";
+ const std::string privilegeB = "http://tizen.org/applicationDefinedPrivilege/app_defined_08b";
+ const std::string privilegeC = "http://tizen.org/applicationDefinedPrivilege/app_defined_08c";
+ const std::string licenseA = "/opt/data/app_defined_08a/res/license";
+ const std::string licenseB = "/opt/data/app_defined_08b/res/license";
+ const std::string licenseC = "/opt/data/app_defined_08c/res/license";
+ const std::string clientId = "app_def_08_client";
+ uid_t uid = 5001;
+
+ AppInstallHelper clientGlobal(clientId);
+ AppInstallHelper clientLocal(clientId, uid);
+ clientGlobal.addClientPrivilege(std::make_pair(privilegeB, licenseB));
+ clientGlobal.addClientPrivilege(std::make_pair(privilegeC, licenseC));
+ clientLocal.addClientPrivilege(std::make_pair(privilegeA, licenseA));
+ clientLocal.addClientPrivilege(std::make_pair(privilegeC, ""));
+ ScopedInstaller req1(clientGlobal);
+ ScopedInstaller req2(clientLocal);
+
+ result = security_manager_get_client_privilege_license(nullptr,
+ clientLocal.getAppId().c_str(),
+ uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_INPUT_PARAM);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_client_privilege_license(privilegeA.c_str(), nullptr,
+ uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_INPUT_PARAM);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_client_privilege_license(privilegeA.c_str(),
+ clientLocal.getAppId().c_str(),
+ uid, nullptr);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_INPUT_PARAM);
+
+ result = security_manager_get_client_privilege_license("noExistingPrivilege",
+ clientLocal.getAppId().c_str(),
+ uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_client_privilege_license(privilegeA.c_str(), "noExistingApp",
+ uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_client_privilege_license(privilegeC.c_str(),
+ clientLocal.getAppId().c_str(),
+ uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_client_privilege_license(privilegeA.c_str(),
+ clientLocal.getAppId().c_str(),
+ uid+1, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_client_privilege_license(privilegeA.c_str(),
+ clientLocal.getAppId().c_str(),
+ uid, &license);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "getting privilege license failed");
+ RUNNER_ASSERT(license && std::string(license) == licenseA);
+ free(license);
+ license = nullptr;
+
+ req2.uninstallApp();
+ result = security_manager_get_client_privilege_license(privilegeB.c_str(),
+ clientGlobal.getAppId().c_str(),
+ uid, &license);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "getting privilege license failed");
+ RUNNER_ASSERT(license && std::string(license) == licenseB);
+ free(license);
+ license = nullptr;
+}