3 test_description
='credential-cache tests'
5 .
"$TEST_DIRECTORY"/lib-credential.sh
7 test -z "$NO_UNIX_SOCKETS" ||
{
8 skip_all
='skipping credential-cache tests, unix sockets not available'
15 test_path_is_socket
() {
16 # `test -S` cannot detect Win10's Unix sockets
21 test_path_is_socket
() {
27 # don't leave a stale daemon running
28 test_atexit
'git credential-cache exit'
30 # test that the daemon works with no special setup
32 helper_test_oauth_refresh_token cache
34 test_expect_success
'socket defaults to ~/.cache/git/credential/socket' '
36 git credential-cache exit &&
37 rmdir -p .cache/git/credential/
39 test_path_is_missing "$HOME/.git-credential-cache" &&
40 test_path_is_socket "$HOME/.cache/git/credential/socket"
43 XDG_CACHE_HOME
="$HOME/xdg"
45 # test behavior when XDG_CACHE_HOME is set
48 test_expect_success
"use custom XDG_CACHE_HOME if set and default sockets are not created" '
49 test_when_finished "git credential-cache exit" &&
50 test_path_is_socket "$XDG_CACHE_HOME/git/credential/socket" &&
51 test_path_is_missing "$HOME/.git-credential-cache/socket" &&
52 test_path_is_missing "$HOME/.cache/git/credential/socket"
56 test_expect_success
'credential-cache --socket option overrides default location' '
58 git credential-cache exit --socket \"\$HOME/dir/socket\" &&
61 check approve "cache --socket \"\$HOME/dir/socket\"" <<-\EOF &&
67 test_path_is_socket "$HOME/dir/socket"
70 test_expect_success
"use custom XDG_CACHE_HOME even if xdg socket exists" '
72 git credential-cache exit &&
73 sane_unset XDG_CACHE_HOME
75 check approve cache <<-\EOF &&
81 test_path_is_socket "$HOME/.cache/git/credential/socket" &&
82 XDG_CACHE_HOME="$HOME/xdg" &&
83 export XDG_CACHE_HOME &&
84 check approve cache <<-\EOF &&
90 test_path_is_socket "$XDG_CACHE_HOME/git/credential/socket"
93 test_expect_success
'use user socket if user directory exists' '
95 git credential-cache exit &&
96 rmdir \"\$HOME/.git-credential-cache/\"
98 mkdir -p "$HOME/.git-credential-cache/" &&
99 chmod 700 "$HOME/.git-credential-cache/" &&
100 check approve cache <<-\EOF &&
106 test_path_is_socket "$HOME/.git-credential-cache/socket"
109 test_expect_success SYMLINKS
'use user socket if user directory is a symlink to a directory' '
111 git credential-cache exit &&
112 rmdir \"\$HOME/dir/\" &&
113 rm \"\$HOME/.git-credential-cache\"
115 mkdir -p -m 700 "$HOME/dir/" &&
116 ln -s "$HOME/dir" "$HOME/.git-credential-cache" &&
117 check approve cache <<-\EOF &&
123 test_path_is_socket "$HOME/.git-credential-cache/socket"
126 helper_test_timeout cache
--timeout=1