From 9b23b86ba4d1e86ecdd474ec70c7bbfa2eaccd1e Mon Sep 17 00:00:00 2001 From: Marcin Lis Date: Wed, 21 Aug 2013 17:46:59 +0200 Subject: [PATCH] Correct api-feature tests [Issue#] SSDWSSP-405 [Bug] Bad string formats [Cause] Bug in libprivilege [Solution] Removed incorrect characters " ------" form checks [Verification] Build and run all tests Change-Id: I906756a14bfc8a136338778464e7e430c7747495 --- tests/libprivilege-control-tests/test_cases.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/libprivilege-control-tests/test_cases.cpp b/tests/libprivilege-control-tests/test_cases.cpp index eedd427..3a23833 100644 --- a/tests/libprivilege-control-tests/test_cases.cpp +++ b/tests/libprivilege-control-tests/test_cases.cpp @@ -1009,17 +1009,12 @@ RUNNER_TEST_SMACK(privilege_control05_add_shared_dir_readers) cleaning_smack_database_files(); //test what happens when the label is not correct SMACK label - result = smack_accesses_new(&rules); - RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new."); - result = add_shared_dir_readers(TEST_OBJ,app_labels_wrong); RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "add_shared_dir_readers should fail here"); result = smack_have_access(app_labels_wrong[0],TEST_OBJ,"rx"); RUNNER_ASSERT_MSG(result != 1, "add_shared_dir_readers should not grant permission here"); - smack_accesses_free(rules); - //ok, now the correct list of apps result = smack_accesses_new(&rules); RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new."); @@ -1029,7 +1024,7 @@ RUNNER_TEST_SMACK(privilege_control05_add_shared_dir_readers) result = perm_app_revoke_permissions(app_labels[i]); RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions."); result = perm_app_uninstall(app_labels[i]); - RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install."); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall."); result = perm_app_install(app_labels[i]); RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install."); @@ -1466,12 +1461,12 @@ RUNNER_TEST(privilege_control11_add_api_feature) // correct rules result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "malformed malformed maaaaaalformed", NULL }, NULL, 0); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "malformed malformed r--a-l ------" }); + osp_blahblah_check(__LINE__, { "malformed malformed r--a-l" }); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "subject object foo", NULL }, NULL, 0); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "subject object ------ ------" }); + osp_blahblah_check(__LINE__, { "subject object ------" }); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { @@ -1482,7 +1477,7 @@ RUNNER_TEST(privilege_control11_add_api_feature) NULL }, NULL, 0); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "subject object rwxatl ------", "subject2 object2 rwxatl ------"}); + osp_blahblah_check(__LINE__, { "subject object rwxatl", "subject2 object2 rwxatl"}); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { @@ -1490,7 +1485,7 @@ RUNNER_TEST(privilege_control11_add_api_feature) NULL }, NULL, 0); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "Sub::jE,ct object rwxa-l ------"}); + osp_blahblah_check(__LINE__, { "Sub::jE,ct object rwxa-l"}); remove_smack_files(); // TODO For now identical/complementary rules are not merged. @@ -1502,14 +1497,14 @@ RUNNER_TEST(privilege_control11_add_api_feature) NULL }, NULL, 0); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "subject object rwxatl ------", "subject object rwxatl ------"}); + osp_blahblah_check(__LINE__, { "subject object rwxatl", "subject object rwxatl"}); remove_smack_files(); // empty group ids result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {0,1,2},0); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "a a ---a-- ------"}); + osp_blahblah_check(__LINE__, { "a a ---a--"}); result = file_exists(OSP_BLAHBLAH_DAC); RUNNER_ASSERT(result == -1); remove_smack_files(); @@ -1519,19 +1514,19 @@ RUNNER_TEST(privilege_control11_add_api_feature) result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {0,1,2},3); printf("%d \n", result); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "a a ---a-- ------"}); + osp_blahblah_check(__LINE__, { "a a ---a--"}); osp_blahblah_dac_check(__LINE__, {0,1,2}); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {0,1,2},1); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "a a ---a-- ------"}); + osp_blahblah_check(__LINE__, { "a a ---a--"}); osp_blahblah_dac_check(__LINE__, {0}); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {1,1,1},3); RUNNER_ASSERT(result == PC_OPERATION_SUCCESS); - osp_blahblah_check(__LINE__, { "a a ---a-- ------"}); + osp_blahblah_check(__LINE__, { "a a ---a--"}); osp_blahblah_dac_check(__LINE__, {1,1,1}); remove_smack_files(); } -- 2.7.4