diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-04-10 21:29:43 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-04-11 16:49:05 -0400 |
| commit | bf2620bcefa64e9c0c28621d9ea7c16e5a40c61b (patch) | |
| tree | 443ead14f938f818a589cf612c016ada45e27fa7 /tests | |
| parent | 7e8d9be0cc168c22cbaf1116bd5b27c0a6076565 (diff) | |
| download | libgit2-bf2620bcefa64e9c0c28621d9ea7c16e5a40c61b.tar.gz | |
fs_path: refactor ownership checks into current user and system
Provide individual file ownership checks for both the current user and
the system user, as well as a combined current user and system user
check.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/util/path.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/util/path.c b/tests/util/path.c index 404c17a2b..2c39e0887 100644 --- a/tests/util/path.c +++ b/tests/util/path.c @@ -737,3 +737,28 @@ void test_path__find_exe_in_path(void) git_str_dispose(&sandbox_path); git__free(orig_path); } + +void test_path__validate_current_user_ownership(void) +{ + bool is_cur; + + cl_must_pass(p_mkdir("testdir", 0777)); + cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "testdir")); + cl_assert_equal_i(is_cur, 1); + + cl_git_rewritefile("testfile", "This is a test file."); + cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "testfile")); + cl_assert_equal_i(is_cur, 1); + +#ifdef GIT_WIN32 + cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "C:\\")); + cl_assert_equal_i(is_cur, 0); + + cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "c:\\path\\does\\not\\exist")); +#else + cl_git_pass(git_fs_path_owner_is_current_user(&is_cur, "/")); + cl_assert_equal_i(is_cur, 0); + + cl_git_fail(git_fs_path_owner_is_current_user(&is_cur, "/path/does/not/exist")); +#endif +} |
