appId = nullptr;
pkgId = nullptr;
}
+
+RUNNER_CHILD_TEST(app_defined_07_get_provider_license)
+{
+ int result;
+ char *license = nullptr;
+ const std::string privilegeA = "http://tizen.org/applicationDefinedPrivilege/app_defined_07a";
+ const std::string privilegeB = "http://tizen.org/applicationDefinedPrivilege/app_defined_07b";
+ const std::string privilegeC = "http://tizen.org/applicationDefinedPrivilege/app_defined_07c";
+ const std::string licenseA = "/opt/data/app_defined_07a/res/license";
+ const std::string licenseB = "/opt/data/app_defined_07b/res/license";
+ const std::string licenseC = "/opt/data/app_defined_07c/res/license";
+ const app_defined_privilege_type licensed = SM_APP_DEFINED_PRIVILEGE_TYPE_LICENSED;
+ const app_defined_privilege_type untrusted = SM_APP_DEFINED_PRIVILEGE_TYPE_UNTRUSTED;
+ const std::string providerId = "app_def_07_provider";
+ uid_t uid = 5001;
+
+ AppInstallHelper providerGlobal(providerId);
+ AppInstallHelper providerLocal(providerId, uid);
+ providerGlobal.addAppDefinedPrivilege(std::make_tuple(privilegeB, licensed, licenseB));
+ providerGlobal.addAppDefinedPrivilege(std::make_tuple(privilegeC, licensed, licenseC));
+ providerLocal.addAppDefinedPrivilege(std::make_tuple(privilegeA, licensed, licenseA));
+ providerLocal.addAppDefinedPrivilege(std::make_tuple(privilegeC, untrusted, ""));
+ ScopedInstaller req1(providerGlobal);
+ ScopedInstaller req2(providerLocal);
+
+ result = security_manager_get_app_defined_privilege_license(nullptr, uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_INPUT_PARAM);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_app_defined_privilege_license(privilegeA.c_str(), uid, nullptr);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_INPUT_PARAM);
+
+ result = security_manager_get_app_defined_privilege_license("noExistingPrivilege", uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_app_defined_privilege_license(privilegeC.c_str(), uid, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_app_defined_privilege_license(privilegeA.c_str(), uid+1, &license);
+ RUNNER_ASSERT(result == SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT);
+ RUNNER_ASSERT(license == nullptr);
+
+ result = security_manager_get_app_defined_privilege_license(privilegeB.c_str(), uid, &license);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "getting privilege provider license failed");
+ RUNNER_ASSERT(license && std::string(license) == licenseB);
+ free(license);
+ license = nullptr;
+
+ result = security_manager_get_app_defined_privilege_license(privilegeA.c_str(), uid, &license);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "getting privilege provider license failed");
+ RUNNER_ASSERT(license && std::string(license) == licenseA);
+ free(license);
+ license = nullptr;
+
+ req2.uninstallApp();
+ result = security_manager_get_app_defined_privilege_license(privilegeC.c_str(), uid, &license);
+ RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "getting privilege provider license failed");
+ RUNNER_ASSERT(license && std::string(license) == licenseC);
+ free(license);
+ license = nullptr;
+}