Add privacy related APIs 45/83145/11 accepted/tizen/common/20160822.132544 accepted/tizen/ivi/20160823.041023 accepted/tizen/mobile/20160823.040912 accepted/tizen/tv/20160823.040939 accepted/tizen/wearable/20160823.041003 submit/tizen/20160822.023804
authorYunjin Lee <yunjin-.lee@samsung.com>
Tue, 9 Aug 2016 09:11:41 +0000 (18:11 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Fri, 19 Aug 2016 04:20:04 +0000 (13:20 +0900)
Change-Id: I9ef913c71107007243e7e21656f4de79b3b4aa0a
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
LICENSE.Apache-2.0 [changed mode: 0755->0644]
packaging/privilege-info.manifest [changed mode: 0755->0644]
packaging/privilege-info.spec [changed mode: 0755->0644]
src/CMakeLists.txt
src/include/privilege_information.h
src/privilege_info.c
test/CMakeLists.txt
test/org.tizen.test-privilege-info.manifest [new file with mode: 0644]
test/org.tizen.test-privilege-info.xml [new file with mode: 0644]
test/tc_privilege_info.c
test/tc_privilege_info_app_privacy.c [new file with mode: 0644]

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 2d2d0d9..2baa1e3
@@ -1,5 +1,5 @@
 Name:    privilege-info
-Summary: Privilege Management
+Summary: Privilege Information
 Version: 0.0.1
 Release: 1
 Group:   System/Libraries
@@ -13,9 +13,13 @@ BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(security-privilege-manager)
+BuildRequires: pkgconfig(cynara-client)
+BuildRequires: pkgconfig(cynara-session)
+BuildRequires: pkgconfig(libsmack)
+BuildRequires: pkgconfig(libtzplatform-config)
 
 %description
-Privilege Information
+Provides Privilege Information(Privilege Info) API
 
 %package -n privilege-info-devel
 Summary: Privilege Info API (Development)
@@ -25,46 +29,36 @@ Requires: %{name} = %{version}-%{release}
 The Privilege Info API provides functions to get privilege information (DEV)
 
 %package -n tc-privilege-info
-Summary: tc-privilege-info
+Summary: Privilege Info TC
 Requires: %{name} = %{version}-%{release}
 
 %description -n tc-privilege-info
-tc-privilege-info
+Privilege Info API Internal Test
 
 %prep
 %setup -q
 
 %build
 
-%if "%{?tizen_profile_name}" == "wearable"
-    __PROFILE_TYPE="WEARABLE"
-%else
-    __PROFILE_TYPE="MOBILE"
-%endif
-
 export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
 export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
 export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
 
 echo cmake . -DPREFIX=%{_prefix} \
-        -DEXEC_PREFIX=%{_exec_prefix} \
         -DLIBDIR=%{_libdir} \
         -DINCLUDEDIR=%{_includedir} \
         -DCMAKE_BUILD_TYPE=%{build_type} \
         -DVERSION=%{version} \
-        -DDPL_LOG="ON" \
-        -DDATADIR=%{_datadir} \
-        -DPROFILE_TYPE="${__PROFILE_TYPE}"
+        -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \
+        -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP
 
 cmake . -DPREFIX=%{_prefix} \
-        -DEXEC_PREFIX=%{_exec_prefix} \
         -DLIBDIR=%{_libdir} \
         -DINCLUDEDIR=%{_includedir} \
         -DCMAKE_BUILD_TYPE=%{build_type} \
         -DVERSION=%{version} \
-        -DDPL_LOG="ON" \
-        -DDATADIR=%{_datadir} \
-        -DPROFILE_TYPE="${__PROFILE_TYPE}"
+        -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \
+        -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP
 
 make %{?jobs:-j%jobs}
 
@@ -75,6 +69,13 @@ cp LICENSE.Apache-2.0 %{buildroot}%{_datadir}/license/privilege-info
 
 %make_install
 
+#%post -n privilege-info -p /sbin/ldconfig
+#%postun -n privilege-info -p /sbin/ldconfig
+
+%post -n tc-privilege-info
+tpk-backend -y org.tizen.test-privilege-info --preload
+cyad -s -k MANIFESTS -c User::App::org.tizen.test-privilege-info -u '*' -p http://tizen.org/privilege/contact.read -t DENY
+
 %files -n privilege-info
 %{_libdir}/libprivilege-info.so.*
 %{_datadir}/license/privilege-info
@@ -86,8 +87,12 @@ cp LICENSE.Apache-2.0 %{buildroot}%{_datadir}/license/privilege-info
 %{_libdir}/pkgconfig/privilege-info.pc
 
 %files -n tc-privilege-info
+%manifest test/org.tizen.test-privilege-info.manifest
+%{TZ_SYS_RO_APP}/org.tizen.test-privilege-info/bin/tc-privilege-info-app-privacy
+%{TZ_SYS_RO_PACKAGES}/org.tizen.test-privilege-info.xml
 %{_bindir}/tc-privilege-info
 
+
 %clean
 rm -rf %{buildroot}
 
index d147f9f..9ef2023 100755 (executable)
@@ -8,7 +8,7 @@ SET(PRIV_INFO_SOURCES
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
 
-SET(requires glib-2.0 dlog security-privilege-manager)
+SET(requires glib-2.0 dlog security-privilege-manager cynara-client cynara-session libsmack)
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires})
 FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
index d708c70..6b115ba 100755 (executable)
@@ -43,7 +43,7 @@ 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 with free() by you.
+ * @remarks @a display_name must be released using free().
  * @param [in] api_version The version of API
  * @param [in] privilege The privilege
  * @param [out] display_name The display name of the privilege
@@ -53,12 +53,12 @@ typedef enum {
  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
  */
-int privilege_info_get_display_name(const char* api_version, const char* privilege, char **display_name);
+int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name);
 
 /**
  * @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 with free() by you.
+ * @remarks @a display_name must be released using free().
  * @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 version of API
@@ -70,12 +70,12 @@ int privilege_info_get_display_name(const char* api_version, const char* privile
  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
  */
-int privilege_info_get_display_name_by_pkgtype(const char* package_type, const char* api_version, const char* privilege, char **display_name);
+int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name);
 
 /**
  * @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 with free() by you.
+ * @remarks @a description must be released using free().
  * @param [in] api_version The version of API
  * @param [in]  privilege The privilege
  * @param [out] description The description of the privilege
@@ -85,12 +85,12 @@ int privilege_info_get_display_name_by_pkgtype(const char* package_type, const c
  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
  */
-int privilege_info_get_description(const charapi_version, const char *privilege, char **description);
+int privilege_info_get_description(const char *api_version, const char *privilege, char **description);
 
 /**
  * @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 with free() by you.
+ * @remarks @a description must be released using free().
  * @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 version of API
@@ -102,7 +102,36 @@ int privilege_info_get_description(const char* api_version, const char *privileg
  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
  */
-int privilege_info_get_description_by_pkgtype(const char* package_type, const char* api_version, const char *privilege, char **description);
+int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description);
+
+/**
+ * @brief Gets the display name of the privacy group in which the given privilege is included.
+ * @since_tizen 3.0
+ * @remarks @a privacy_name must be released using free().
+ * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned.
+ * @param [in] privilege The privilege
+ * @param [out] privacy_name The privacy group's display name that the given privilege is included in
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVINFO_ERROR_NONE Successful
+ * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ */
+int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_name);
+
+/**
+ * @brief Gets the status of the given privacy related privilege.
+ * @since_tizen 3.0
+ * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned.
+ * @remarks In case of errors, @a status is set to true.
+ * @param [in] privilege The privilege
+ * @param [out] status true if the privilege is on and false if the privilege is off.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVINFO_ERROR_NONE Successful
+ * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ */
+int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status);
 /**
  * @}
  */
index 6f17e30..b95f573 100755 (executable)
@@ -3,12 +3,18 @@
 #include <libintl.h>
 #include <dlog.h>
 #include <privilege_db_manager.h>
+#include <cynara-session.h>
+#include <cynara-client.h>
+#include <unistd.h>
+#include <sys/smack.h>
 #include "privilege_information.h"
 #ifdef LOG_TAG
 #undef LOG_TAG
 #define LOG_TAG "PRIVILEGE_INFO"
 #endif
 
+#define UIDMAXLEN 10
+
 #define TryReturn(condition, expr, returnValue, ...)  \
        if (!(condition)) { \
                expr; \
@@ -24,7 +30,7 @@ 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)
+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");
@@ -100,7 +106,7 @@ 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)
+int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name)
 {
        int ret = 0;
        char* string_id = NULL;
@@ -139,7 +145,7 @@ int privilege_info_get_display_name(const char* api_version, const char* privile
 
 
 PI_API
-int privilege_info_get_description(const char* api_version, const char* privilege, char** description)
+int privilege_info_get_description(const char *api_version, const char *privilege, char **description)
 {
        int ret = 0;
        char* string_id = NULL;
@@ -163,7 +169,7 @@ int privilege_info_get_description(const char* api_version, const char* privileg
 }
 
 PI_API
-int privilege_info_get_display_name_by_pkgtype(const const char* package_type, const char* api_version, const char* privilege, char** display_name)
+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;
@@ -201,7 +207,7 @@ int privilege_info_get_display_name_by_pkgtype(const const char* package_type, c
 }
 
 PI_API
-int privilege_info_get_description_by_pkgtype(const char* package_type, const char* api_version, const char* privilege, char** description)
+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;
@@ -226,3 +232,62 @@ int privilege_info_get_description_by_pkgtype(const char* package_type, const ch
        return PRVINFO_ERROR_NONE;
 }
 
+PI_API
+int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_display_name)
+{
+       TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+       TryReturn(privilege_db_manager_is('p', privilege) == 1, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related");
+
+       char* privacy_id = NULL;
+       char* privacy_display_string_id = NULL;
+
+       TryReturn(privilege_db_manager_get_privacy_by_privilege(privilege, &privacy_id) == PRIVILEGE_DB_MANAGER_ERR_NONE, , PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_db_manager_get_privacy_by_privilege failed");
+       TryReturn(privacy_id != NULL, , PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_db_manager_get_privacy_by_privilege failed");
+
+       TryReturn(privilege_db_manager_get_privacy_display(privacy_id, &privacy_display_string_id) == PRIVILEGE_DB_MANAGER_ERR_NONE, free(privacy_id), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_db_manager_get_privacy_display failed");
+       TryReturn(privilege_info_get_string_by_string_id(privacy_display_string_id, privacy_display_name) == PRVINFO_ERROR_NONE, free(privacy_id); free(privacy_display_string_id), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+       TryReturn(*privacy_display_name != NULL, free(privacy_id), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] privilege_db_manager_get_privacy_display failed");
+
+       free(privacy_id);
+       return PRVINFO_ERROR_NONE;
+}
+
+PI_API
+int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status)
+{
+       TryReturn(privilege != NULL, *status = true, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+       TryReturn(privilege_db_manager_is('p', privilege) == 1, *status = true, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related");
+
+       char* smack_label = NULL;
+       TryReturn(smack_new_label_from_self(&smack_label) != -1, *status = true, PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] smack_new_label_from_self() failed.");
+
+       cynara *cynara = NULL;
+       TryReturn(cynara_initialize(&cynara, NULL) == CYNARA_API_SUCCESS, *status = true; cynara = NULL, PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_initialize() failed.");
+
+       char *session = NULL;
+       session = cynara_session_from_pid(getpid());
+       TryReturn(session != NULL, *status = true; cynara_finish(cynara), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] cynara_session_from_pid() failed");
+
+       char uid[UIDMAXLEN];
+       int result = snprintf(uid, UIDMAXLEN, "%d", getuid());
+       TryReturn(uid != NULL && result > 0, *status = true; free(session); cynara_finish(cynara), PRVINFO_ERROR_INTERNAL_ERROR, "[PRVINFO_ERROR_INTERNAL_ERROR] snprintf() for uid failed.");
+
+       result = cynara_check(cynara, smack_label, session, uid, privilege);
+       int ret = PRVINFO_ERROR_NONE;
+       free(session);
+       cynara_finish(cynara);
+
+       LOGD("result of cynara_check(cynara %s, session, %s, %s) result = %d", smack_label, uid, privilege, result);
+       if (result == CYNARA_API_ACCESS_DENIED) {
+               *status = false;
+       } else if (result == CYNARA_API_ACCESS_ALLOWED) {
+               *status = true;
+       } else {
+               *status = true;
+               LOGE("[PRVINFO_ERROR_INTERNAL_ERROR] cynara_check() failed. ret = %d", result);
+               ret = PRVINFO_ERROR_INTERNAL_ERROR;
+       }
+
+       return ret;
+}
+
index 9972e42..18d6f42 100755 (executable)
@@ -3,7 +3,10 @@ SET(PACKAGE_NAME tc-privilege-info)
 PROJECT(${PACKAGE_NAME})
 
 SET(TC1_NAME tc-privilege-info)
+SET(TC2_NAME tc-privilege-info-app-privacy)
+
 SET(TC1_SRCS ${PROJECT_SOURCE_DIR}/tc_privilege_info.c)
+SET(TC2_SRCS ${PROJECT_SOURCE_DIR}/tc_privilege_info_app_privacy.c)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include)
 
@@ -14,11 +17,15 @@ FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -fvisibility=hidden -D_WITH_SYSTEMD_")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${PACKAGE_NAME_CFLAGS}")
-                                                                                                                                                
+
 ADD_EXECUTABLE(${TC1_NAME} ${TC1_SRCS})
+ADD_EXECUTABLE(${TC2_NAME} ${TC2_SRCS})
 TARGET_LINK_LIBRARIES(${TC1_NAME} "privilege-info")
+TARGET_LINK_LIBRARIES(${TC2_NAME} "privilege-info")
+
+INSTALL(TARGETS ${TC1_NAME} DESTINATION /usr/bin)
+INSTALL(TARGETS ${TC2_NAME} DESTINATION ${TZ_SYS_RO_APP}/org.tizen.test-privilege-info/bin/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/test/org.tizen.test-privilege-info.xml DESTINATION ${TZ_SYS_RO_PACKAGES})
 
-INSTALL(TARGETS ${TC1_NAME} DESTINATION /usr/bin)
\ No newline at end of file
diff --git a/test/org.tizen.test-privilege-info.manifest b/test/org.tizen.test-privilege-info.manifest
new file mode 100644 (file)
index 0000000..ccea6a9
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+    <request>
+               <domain name="_" />
+       </request>
+</manifest>
+
diff --git a/test/org.tizen.test-privilege-info.xml b/test/org.tizen.test-privilege-info.xml
new file mode 100644 (file)
index 0000000..c9d7ab2
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.test-privilege-info" version="1.0.1" install-location="internal-only">
+    <ui-application appid="org.tizen.test-privilege-info" exec="tc-privilege-info-app-privacy" nodisplay="true" multiple="false" type ="capp" taskmanage="false" component-type="svcapp">
+        <label>org.tizen.test-privilege-info</label>
+    </ui-application>
+    <privileges>
+        <privilege>http://tizen.org/privilege/account.read</privilege>
+        <privilege>http://tizen.org/privilege/contact.read</privilege>
+    </privileges>
+</manifest>
+
+
index 233f65a..08de15d 100755 (executable)
@@ -127,6 +127,28 @@ static void __check_get_privilege_description_result(privilege_info_error_e expe
        __change_color_to_origin();
 }
 
+static void __check_get_privacy_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* privacy_display)
+{
+       printf("expectd result %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+       if (expected_result != result) {
+               printf("not matched\n");
+               __change_color_to_red();
+               printf("test fail\n");
+               fail_cnt++;
+       } else {
+               printf("matched\n");
+               if (privacy_display != NULL)
+                       printf("privacy_display_name = %s\n", privacy_display);
+               else
+                       printf("privacy_display_name is NULL.\n");
+               __change_color_to_green();
+               printf("test success\n");
+               success_cnt++;
+       }
+       __change_color_to_origin();
+}
+
 static void __test_privilege_info_get_display_name()
 {
        int ret;
@@ -355,6 +377,53 @@ static void __test_privilege_info_get_description_by_pkgtype()
        free(description);
 }
 
+static void __test_privilege_info_get_privacy_display_name()
+{
+       int ret;
+       char* privacy_display_name = NULL;
+
+       printf("-----------------------------------------------------------\n");
+       printf("Invalid parameter\n");
+       printf("no input privilege\n");
+       ret = privilege_info_get_privacy_display_name(NULL, &privacy_display_name);
+       __check_get_privacy_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, privacy_display_name);
+
+       if (privacy_display_name != NULL) {
+               free(privacy_display_name);
+               privacy_display_name = NULL;
+       }
+
+       printf("-----------------------------------------------------------\n");
+       printf("Not a privacy related privilege\n");
+       printf("privilege: http://tizen.org/privilege/internet\n");
+       ret = privilege_info_get_privacy_display_name("http://tizen.org/privilege/internet", &privacy_display_name);
+       __check_get_privacy_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, privacy_display_name);
+
+       if (privacy_display_name != NULL) {
+               free(privacy_display_name);
+               privacy_display_name = NULL;
+       }
+
+       printf("-----------------------------------------------------------\n");
+       printf("Not existing privilege\n");
+       printf("privilege: http://tizen.org/privilege/wrong.privilege.name\n");
+       ret = privilege_info_get_privacy_display_name("http://tizen.org/privilege/wrong.privilege.name", &privacy_display_name);
+       __check_get_privacy_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, privacy_display_name);
+
+       if (privacy_display_name != NULL) {
+               free(privacy_display_name);
+               privacy_display_name = NULL;
+       }
+
+       printf("-----------------------------------------------------------\n");
+       printf("Privacy related privilege\n");
+       printf("privilege: http://tizen.org/privilege/account.read\n");
+       ret = privilege_info_get_privacy_display_name("http://tizen.org/privilege/account.read", &privacy_display_name);
+       __check_get_privacy_display_name_result(PRVINFO_ERROR_NONE, ret, privacy_display_name);
+
+       free(privacy_display_name);
+}
+
 int main()
 {
        __change_color_to_yellow();
@@ -377,6 +446,11 @@ int main()
        __change_color_to_origin();
        __test_privilege_info_get_description_by_pkgtype();
 
+       __change_color_to_yellow();
+       printf("Test function : privilege_info_get_privacy_display_name\n");
+       __change_color_to_origin();
+       __test_privilege_info_get_privacy_display_name();
+
        __change_color_to_green();
        printf("Test Complete\n");
        printf("success : %d, ", success_cnt);
diff --git a/test/tc_privilege_info_app_privacy.c b/test/tc_privilege_info_app_privacy.c
new file mode 100644 (file)
index 0000000..6df037c
--- /dev/null
@@ -0,0 +1,86 @@
+#include <stdio.h>
+#include <dlog.h>
+#include <stdbool.h>
+#include <privilege_information.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "PRIVILEGE_INFO_TEST_APP"
+#endif
+
+
+static int fail_cnt = 0;
+static int success_cnt = 0;
+
+static const char *__get_result_string(privilege_info_error_e ret)
+{
+       if (ret == PRVINFO_ERROR_NONE)
+               return "PRVINFO_ERROR_NONE";
+       else if (ret == PRVINFO_ERROR_INVALID_PARAMETER)
+               return "PRVINFO_ERROR_INVALID_PARAMETER";
+       else if (ret == PRVINFO_ERROR_INTERNAL_ERROR)
+               return "PRVINFO_ERROR_INTERNAL_ERROR";
+       else if (ret == PRVINFO_ERROR_OUT_OF_MEMORY)
+               return "PRVINFO_ERROR_UNDECLARED_PRIVILEGE";
+       else
+               return "FAIL";
+}
+
+static void __check_result(privilege_info_error_e expected_result, privilege_info_error_e result, bool expected_status, bool status)
+{
+       LOGD("expected result = %s, result = %s", __get_result_string(expected_result), __get_result_string(result));
+       LOGD("expected status = %s, status = %s", expected_status ? "true" : "false", status ? "true" : "false");
+
+       if (expected_result != result) {
+               LOGD("test fail");
+               fail_cnt++;
+       } else {
+               if (expected_status != status) {
+                       LOGD("test fail");
+                       fail_cnt++;
+               } else {
+                       LOGD("test success");
+                       success_cnt++;
+               }
+       }
+}
+
+static void __test_privilege_info_get_privacy_privilege_status()
+{
+       int ret = PRVINFO_ERROR_NONE;
+       bool status;
+
+       LOGD("-----------------------------------------------------------");
+       LOGD("privilege : http://tizen.org/privilege/account.read");
+       LOGD("expected result : PRVINFO_ERROR_NONE");
+       ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/account.read", &status);
+       __check_result(PRVINFO_ERROR_NONE, ret, true, status);
+       LOGD("-----------------------------------------------------------");
+
+       LOGD("privilege : http://tizen.org/privilege/contact.read");
+       LOGD("expected result : PRVINFO_ERROR_NONE");
+       ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/contact.read", &status);
+       __check_result(PRVINFO_ERROR_NONE, ret, false, status);
+       LOGD("-----------------------------------------------------------");
+
+       LOGD("privilege : http://tizen.org/privilege/aaaaa");
+       LOGD("expected result : PRVINFO_ERROR_INVALID_PARAMETER");
+       ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/aaaaa", &status);
+       __check_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, true, status);
+       LOGD("-----------------------------------------------------------");
+
+}
+
+int main()
+{
+       LOGD("Test function : privilege_info_get_privacy_privilege_status");
+       __test_privilege_info_get_privacy_privilege_status();
+
+       LOGD("====================================");
+       LOGD("Test Complete");
+       LOGD("success : %d, ", success_cnt);
+       LOGD("fail : %d", fail_cnt);
+       LOGD("====================================");
+
+       return 0;
+}