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_password_expiry_utc cache
33 helper_test_oauth_refresh_token cache
35 test_expect_success
'socket defaults to ~/.cache/git/credential/socket' '
37 git credential-cache exit &&
38 rmdir -p .cache/git/credential/
40 test_path_is_missing "$HOME/.git-credential-cache" &&
41 test_path_is_socket "$HOME/.cache/git/credential/socket"
44 XDG_CACHE_HOME
="$HOME/xdg"
46 # test behavior when XDG_CACHE_HOME is set
49 test_expect_success
"use custom XDG_CACHE_HOME if set and default sockets are not created" '
50 test_when_finished "git credential-cache exit" &&
51 test_path_is_socket "$XDG_CACHE_HOME/git/credential/socket" &&
52 test_path_is_missing "$HOME/.git-credential-cache/socket" &&
53 test_path_is_missing "$HOME/.cache/git/credential/socket"
57 test_expect_success
'credential-cache --socket option overrides default location' '
59 git credential-cache exit --socket \"\$HOME/dir/socket\" &&
62 check approve "cache --socket \"\$HOME/dir/socket\"" <<-\EOF &&
68 test_path_is_socket "$HOME/dir/socket"
71 test_expect_success
"use custom XDG_CACHE_HOME even if xdg socket exists" '
73 git credential-cache exit &&
74 sane_unset XDG_CACHE_HOME
76 check approve cache <<-\EOF &&
82 test_path_is_socket "$HOME/.cache/git/credential/socket" &&
83 XDG_CACHE_HOME="$HOME/xdg" &&
84 export XDG_CACHE_HOME &&
85 check approve cache <<-\EOF &&
91 test_path_is_socket "$XDG_CACHE_HOME/git/credential/socket"
94 test_expect_success
'use user socket if user directory exists' '
96 git credential-cache exit &&
97 rmdir \"\$HOME/.git-credential-cache/\"
99 mkdir -p "$HOME/.git-credential-cache/" &&
100 chmod 700 "$HOME/.git-credential-cache/" &&
101 check approve cache <<-\EOF &&
107 test_path_is_socket "$HOME/.git-credential-cache/socket"
110 test_expect_success SYMLINKS
'use user socket if user directory is a symlink to a directory' '
112 git credential-cache exit &&
113 rmdir \"\$HOME/dir/\" &&
114 rm \"\$HOME/.git-credential-cache\"
116 mkdir -p -m 700 "$HOME/dir/" &&
117 ln -s "$HOME/dir" "$HOME/.git-credential-cache" &&
118 check approve cache <<-\EOF &&
124 test_path_is_socket "$HOME/.git-credential-cache/socket"
127 helper_test_timeout cache
--timeout=1