Increasing negative test cases for privilege_package_info.c 23/318723/2
authorLe <xuan.tien@samsung.com>
Mon, 7 Oct 2024 10:18:57 +0000 (17:18 +0700)
committerDariusz Michaluk <d.michaluk@samsung.com>
Fri, 11 Oct 2024 14:08:23 +0000 (14:08 +0000)
Change-Id: I6cf9e8755eca80f6e42df7af13559fe39bccaece
Signed-off-by: Le <xuan.tien@samsung.com>
test/tc-privilege-package-info.c

index 677f68451a1e1d60285c7a1d4e446a2bdfe17271..36d3a4278c45dc420f79c57755e277fe97bb11d0 100644 (file)
@@ -95,6 +95,17 @@ void __test_privilege_package_info()
        /* Test */
        __print_line();
        __tcinfo(function, "privilege_package_info_is_privacy_requestable");
+
+       __tcinfo(goal, NEG_TC_PREFIX "uid 5001, api-version=3.0, pkgid=NULL");
+       ret = privilege_package_info_is_privacy_requestable(5001, NULL, "http://tizen.org/privilege/call", &is_requestable);
+       expect_result = (ret == PRVMGR_ERR_INVALID_PARAMETER);
+       __output_privilege_package_info_is_privacy_requestable(expect_result, is_requestable, ret);
+
+       __tcinfo(goal, NEG_TC_PREFIX "uid 5001, api-version=3.0, org.test.nativeapp_3, with no exist privilege");
+       ret = privilege_package_info_is_privacy_requestable(5001, "org.test.nativeapp_3", "http://tizen.org/privilege/ffffffsasas", &is_requestable);
+       expect_result = (ret == PRVMGR_ERR_NONE && !is_requestable);
+       __output_privilege_package_info_is_privacy_requestable(expect_result, is_requestable, ret);
+
        __tcinfo(goal, POS_TC_PREFIX "see if uid 5001, api-version=3.0, org.test.nativeapp_3 can request privacy for http://tizen.org/privilege/call");
        ret = privilege_package_info_is_privacy_requestable(5001, "org.test.nativeapp_3", "http://tizen.org/privilege/call", &is_requestable);
        expect_result = (ret == PRVMGR_ERR_NONE && !is_requestable);
@@ -126,8 +137,28 @@ void __test_privilege_package_info()
        __output_privilege_package_info_is_privacy_requestable(expect_result, is_requestable, ret);
 
        __tcinfo(function, "privilege_package_info_get_privacy_list_by_pkgid");
-       __tcinfo(goal, POS_TC_PREFIX "get privacy list of org.test.nativeapp_3");
+
+       __tcinfo(goal, NEG_TC_PREFIX "get privacy list of org.test.nativeapp_3 with pkgid=NULL");
        GList* tmp_list = NULL;
+       ret = privilege_package_info_get_privacy_list_by_pkgid(5001, NULL, &tmp_list);
+       __tcinfo(expect, PRVMGR_ERR_INVALID_PARAMETER);
+       __print_result('m', ret);
+
+       __tcinfo(goal, NEG_TC_PREFIX "get privacy list of org.test.nativeapp_3 with invalid pkgid");
+       ret = privilege_package_info_get_privacy_list_by_pkgid(5001, "abcdef", &tmp_list);
+       __tcinfo(expect, PRVMGR_ERR_NONE);
+       __tcinfo(ret, __get_result_string('m', expected_result), __get_result_string('m', ret));
+       if(tmp_list == NULL && ret == expected_result) {
+               success_cnt++;
+               __color_to_green();
+               printf(">> test success\n");
+       } else {
+               fail_cnt++;
+               __color_to_bold_red();
+               printf(">> test fail\n");
+       }
+
+       __tcinfo(goal, POS_TC_PREFIX "get privacy list of org.test.nativeapp_3");
        ret = privilege_package_info_get_privacy_list_by_pkgid(5001, "org.test.nativeapp_3", &tmp_list);
        __tcinfo(expect, PRVMGR_ERR_NONE);
        __print_result('m', ret);
@@ -138,6 +169,16 @@ void __test_privilege_package_info()
 
        __print_line();
        __tcinfo(function, "privilege_package_info_get_package_list_by_privacy");
+
+       __tcinfo(goal, NEG_TC_PREFIX "get list of packages with null privacy");
+       ret = privilege_package_info_get_package_list_by_privacy(5001, NULL, &tmp_list);
+       __tcinfo(expect, PRVMGR_ERR_INVALID_PARAMETER);
+       __print_result('m', ret);
+       if (tmp_list != NULL) {
+               __print_glist(tmp_list);
+               gfree(tmp_list);
+       }
+
        __tcinfo(goal, POS_TC_PREFIX "get list of packages with bookmark privacy");
        ret = privilege_package_info_get_package_list_by_privacy(5001, "http://tizen.org/privacy/bookmark", &tmp_list);
        __tcinfo(expect, PRVMGR_ERR_NONE);
@@ -159,6 +200,25 @@ void __test_privilege_package_info()
 
        __print_line();
        __tcinfo(function, "privilege_package_info_get_privilege_list_by_pkgid_and_privacy");
+
+       __tcinfo(goal, NEG_TC_PREFIX "get privilege list of org.test.nativeapp_3's NULL privacy");
+       ret = privilege_package_info_get_privilege_list_by_pkgid_and_privacy(5001, "org.test.nativeapp_3", NULL, &tmp_list);
+       __tcinfo(expect, PRVMGR_ERR_INVALID_PARAMETER);
+       __print_result('m', ret);
+       if (tmp_list != NULL) {
+               __print_glist(tmp_list);
+               gfree(tmp_list);
+       }
+
+       __tcinfo(goal, NEG_TC_PREFIX "get privilege list of org.test.nativeapp_3's NULL pkgid");
+       ret = privilege_package_info_get_privilege_list_by_pkgid_and_privacy(5001, NULL, "http://tizen.org/privacy/account", &tmp_list);
+       __tcinfo(expect, PRVMGR_ERR_INVALID_PARAMETER);
+       __print_result('m', ret);
+       if (tmp_list != NULL) {
+               __print_glist(tmp_list);
+               gfree(tmp_list);
+       }
+
        __tcinfo(goal, POS_TC_PREFIX "get privilege list of org.test.nativeapp_3's account privacy");
        ret = privilege_package_info_get_privilege_list_by_pkgid_and_privacy(5001, "org.test.nativeapp_3", "http://tizen.org/privacy/account", &tmp_list);
        __tcinfo(expect, PRVMGR_ERR_NONE);