From: Yunjin Lee Date: Tue, 12 May 2020 09:47:36 +0000 (+0000) Subject: Revert "Return error if there's no matched privilege" X-Git-Tag: submit/tizen/20200512.095222~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F233128%2F1;p=platform%2Fcore%2Fsecurity%2Fprivilege-info.git Revert "Return error if there's no matched privilege" This reverts commit 53351337cfb127e2e536471e8fb1d6ed53a8fcc9. Change-Id: I35f8292f68325a9f2084bc2aaae11b2157c82943 --- diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h index d47d785..b8119dd 100755 --- a/doc/privilege-info_doc.h +++ b/doc/privilege-info_doc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014 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,7 +28,7 @@ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_OVERVIEW Overview * A library for reading privilege information of the given privilege and API issue version. * It provides the display name or description of privileges. - * If there's no matching privilege then it returns error. + * If there's no matching privilege then it shows last token of given privilege or description string for undefined privileges. * * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features * This API is related with the following features:\n diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index 6201068..b4fc806 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -107,7 +107,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %post -n tc-privilege-info tpk-backend -y org.tizen.test-privilege-info --preload -cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY +cyad -s -k MANIFESTS -c User::Pkg::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY %files -n privilege-info %{_libdir}/libprivilege-info.so* diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h index 29e83f2..fa525da 100755 --- a/src/include/privilege_information.h +++ b/src/include/privilege_information.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-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. @@ -46,8 +46,7 @@ typedef enum { PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */ - PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 5.0) */ - PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 /**< No matched privilege (Since 6.0) */ + PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 5.0) */ } privilege_info_error_e; @@ -55,14 +54,12 @@ typedef enum { * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] display_name The display name of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -74,8 +71,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @brief Gets the display name of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a display_name must be released using free(). - * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -83,7 +79,6 @@ int privilege_info_get_display_name(const char *api_version, const char *privile * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -95,14 +90,12 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege * @param[out] description The description of the privilege * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error @@ -114,8 +107,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @brief Gets the description of the given privilege. * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif * @remarks @a description must be released using free(). - * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" - * @remarks Since 6.0, it will return #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege not exist. + * @remarks package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB" * @param[in] package_type The type of application package * @param[in] api_version The API version of the application to get privilege information * @param[in] privilege The privilege @@ -123,7 +115,6 @@ int privilege_info_get_description(const char *api_version, const char *privileg * @return @c 0 on success, * otherwise a negative error value * @retval #PRVINFO_ERROR_NONE Successful - * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error diff --git a/src/privilege_information.c b/src/privilege_information.c index 1c7687b..aa1cffa 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2014-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. @@ -65,8 +65,15 @@ #define PI_API __attribute__((visibility("default"))) #endif +typedef enum { + PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 +} privilege_info_internal_error_e; + int privilege_info_get_string_id(const char *package_type_string, int display, const char *api_version, const char *privilege, char **string_id) { + TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); + TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + char* temp = NULL; int ret; privilege_manager_package_type_e package_type; @@ -80,10 +87,10 @@ int privilege_info_get_string_id(const char *package_type_string, int display, c else ret = privilege_db_manager_get_privilege_description(PRVMGR_PACKAGE_TYPE_CORE, privilege, api_version, &temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) - goto string_id_found; + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) + goto err_none; else if (ret != PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - goto err; + goto err_internal_error; /* Check WEB */ @@ -100,31 +107,35 @@ get_string_id_with_package_type: else ret = privilege_db_manager_get_privilege_description(package_type, privilege, api_version, &temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && temp != NULL) - goto string_id_found; + + if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE) + goto err_none; + else if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) + goto err_no_matching_privilege; else - goto err; + goto err_internal_error; -string_id_found: +err_none: *string_id = strdup(temp); TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); free(temp); return PRVINFO_ERROR_NONE; -err: +err_no_matching_privilege: *string_id = NULL; - if (temp != NULL) - free(temp); - if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) - return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; - else - return PRVINFO_ERROR_INTERNAL_ERROR; + free(temp); + return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE; + +err_internal_error: + free(temp); + return PRVINFO_ERROR_INTERNAL_ERROR; } int privilege_info_get_string_by_string_id(const char *string_id, char **string) { + char *temp = NULL; TryReturn(string_id != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL"); - char* temp = NULL; + temp = dgettext("privilege", string_id); *string = strdup(temp); @@ -136,80 +147,129 @@ int privilege_info_get_string_by_string_id(const char *string_id, char **string) PI_API int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name) { - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); - TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; char* string_id = NULL; + TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); + TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + ret = privilege_info_get_string_id(NULL, 1, api_version, privilege, &string_id); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + char* tempPrivilege = NULL; + char* token = NULL; + char* temp = NULL; + char* save = NULL; + + tempPrivilege = strdup(privilege); + TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); + + token = strtok_r(tempPrivilege, "/", &save); + while (token) { + temp = token; + token = strtok_r(NULL, "/", &save); + } + TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); + *display_name = strdup(temp); + TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + free(tempPrivilege); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, display_name); - if (string_id != NULL) free(string_id); - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API int privilege_info_get_description(const char *api_version, const char *privilege, char **description) { - TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); - TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; char* string_id = NULL; + TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); + TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); + ret = privilege_info_get_string_id(NULL, 0, api_version, privilege, &string_id); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, description); - if (string_id != NULL) free(string_id); - - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name) { + int ret = 0; + char* string_id = NULL; + TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - ret = privilege_info_get_string_id(package_type, 1, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + char* tempPrivilege = NULL; + char* token = NULL; + char* temp = NULL; + char* save = NULL; + tempPrivilege = strdup(privilege); + TryReturn(tempPrivilege != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] tempPrivilege's strdup is failed."); + token = strtok_r(tempPrivilege, "/", &save); + while (token) { + temp = token; + token = strtok_r(NULL, "/", &save); + } + TryReturn(temp != NULL, free(tempPrivilege), PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid privilege <%s>", privilege); + *display_name = strdup(temp); + TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + free(tempPrivilege); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, display_name); - if (string_id != NULL) free(string_id); - - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description) { + int ret = 0; + char* string_id = NULL; + TryReturn(package_type != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL"); TryReturn(api_version != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL"); TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL"); - int ret = 0; - char* string_id = NULL; - ret = privilege_info_get_string_id(package_type, 0, api_version, privilege, &string_id); TryReturn(ret != PRVINFO_ERROR_INVALID_PARAMETER, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] invalid package_type : %s", package_type); - if (ret == PRVINFO_ERROR_NONE) + if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else if (ret == PRVINFO_ERROR_NONE) { ret = privilege_info_get_string_by_string_id(string_id, description); - if (string_id != NULL) free(string_id); - - return ret; + TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); + } else { + return PRVINFO_ERROR_INTERNAL_ERROR; + } + return PRVINFO_ERROR_NONE; } PI_API diff --git a/test/tc_privilege_info.c b/test/tc_privilege_info.c index c4f992b..ecc8b9f 100755 --- a/test/tc_privilege_info.c +++ b/test/tc_privilege_info.c @@ -43,15 +43,13 @@ static const char* __get_result_string(privilege_info_error_e ret) return "PRVINFO_ERROR_INTERNAL_ERROR"; else if (ret == PRVINFO_ERROR_NOT_SUPPORTED) return "PRVINFO_ERROR_NOT_SUPPORTED"; - else if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) - return "PRVINFO_ERROR_NO_MATCHING_PRIVILEGE"; return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE"; } static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -71,7 +69,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp } else { printf("display_name = %s\n", display_name); } - } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + } else { if (display_name != NULL) { printf("display_name = %s\n", display_name); printf("display_name must be NULL\n"); @@ -92,7 +90,7 @@ static void __check_get_privilege_display_name_result(privilege_info_error_e exp static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -112,7 +110,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe } else { printf("description = %s\n", description); } - } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) { + } else { if (description != NULL) { printf("description = %s\n", description); printf("description must be NULL\n"); @@ -133,7 +131,7 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe static void __check_get_privacy_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* privacy_display) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expectd result %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { printf("not matched\n"); @@ -161,12 +159,14 @@ static void __test_privilege_info_get_display_name() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -178,17 +178,19 @@ static void __test_privilege_info_get_display_name() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : NULL\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -198,7 +200,6 @@ static void __test_privilege_info_get_display_name() free(display_name); } - static void __test_privilege_info_get_display_name_by_pkgtype() { int ret; @@ -208,6 +209,7 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name); __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); @@ -215,6 +217,7 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -227,29 +230,32 @@ static void __test_privilege_info_get_display_name_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; } ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name); - __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name); + __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (display_name != NULL) { free(display_name); display_name = NULL; @@ -268,12 +274,14 @@ static void __test_privilege_info_get_description() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -285,17 +293,19 @@ static void __test_privilege_info_get_description() printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -314,12 +324,14 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/window.priority.set\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description); __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; @@ -332,28 +344,31 @@ static void __test_privilege_info_get_description_by_pkgtype() printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/mediacapture\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("Not existing privilege\n"); printf("api_version : 2.3\n"); printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); if (description != NULL) { free(description); description = NULL; } ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description); - __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description); + __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description); printf("-----------------------------------------------------------\n"); printf("Invalid parameter\n"); printf("api_version : 2.3\n"); printf("privilege : NULL\n"); + printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n"); if (description != NULL) { free(description); description = NULL; @@ -413,15 +428,15 @@ static void __test_privilege_info_get_privacy_display_name() static void __check_privilege_info_get_privilege_info(privilege_info_error_e expected_result, privilege_info_error_e result, GList* privilege_info_list, int return_result) { - printf("expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result)); + printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result)); if (expected_result != result) { __change_color_to_yellow(); - printf("not matched\n"); + printf("not mached\n"); __change_color_to_origin(); } else { __change_color_to_green(); - printf("matched\n"); + printf("mached\n"); __change_color_to_origin(); } @@ -453,6 +468,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -470,6 +486,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/systemsettings.admin\n"); printf("privilege name : http://tizen.org/privilege/bookmark.admin\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/systemsettings.admin"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/bookmark.admin"); @@ -487,6 +504,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx"); @@ -504,6 +522,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/call\n"); printf("privilege name : http://tizen.org/privilege/content.read\n"); printf("privilege name : http://tizen.org/privilege/filesystem.read\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read"); @@ -521,6 +540,7 @@ static void __test_privilege_info_get_privilege_info_list() printf("privilege name : http://tizen.org/privilege/xxxx\n"); printf("privilege name : http://tizen.org/privilege/alarm.xxxx\n"); printf("privilege name : http://tizen.org/privilege/account.xxx\n"); + printf("expected result : PRVINFO_ERROR_NONE\n"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx"); privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx");