3 . "$(dirname "$0")/testlib.sh"
5 begin_test "http.<url>.extraHeader"
9 reponame="copy-headers"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
13 url="$(git config remote.origin.url).git/info/lfs"
14 git config --add "http.$url.extraHeader" "X-Foo: bar"
15 git config --add "http.$url.extraHeader" "X-Foo: baz"
18 printf "contents" > a.dat
19 git add .gitattributes a.dat
20 git commit -m "initial commit"
22 GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push origin master 2>&1 | tee curl.log
24 grep "> X-Foo: bar" curl.log
25 grep "> X-Foo: baz" curl.log
29 begin_test "http.<url>.extraHeader with authorization"
33 reponame="requirecreds-extraHeader"
34 setup_remote_repo "$reponame"
35 clone_repo "$reponame" "$reponame"
37 # See: test/cmd/lfstest-gitserver.go:missingRequiredCreds().
40 auth="Basic $(echo -n $user:$pass | base64)"
42 git config --add "http.extraHeader" "Authorization: $auth"
45 printf "contents" > a.dat
46 git add .gitattributes a.dat
47 git commit -m "initial commit"
49 git push origin master 2>&1 | tee curl.log
50 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
51 echo >&2 "expected \`git push origin master\` to succeed, didn't"
55 [ "0" -eq "$(grep -c "creds: filling with GIT_ASKPASS" curl.log)" ]
56 [ "0" -eq "$(grep -c "creds: git credential approve" curl.log)" ]
57 [ "0" -eq "$(grep -c "creds: git credential cache" curl.log)" ]
58 [ "0" -eq "$(grep -c "creds: git credential fill" curl.log)" ]
59 [ "0" -eq "$(grep -c "creds: git credential reject" curl.log)" ]
63 begin_test "http.<url>.extraHeader with authorization (casing)"
67 reponame="requirecreds-extraHeaderCasing"
68 setup_remote_repo "$reponame"
69 clone_repo "$reponame" "$reponame"
71 # See: test/cmd/lfstest-gitserver.go:missingRequiredCreds().
74 auth="Basic $(echo -n $user:$pass | base64)"
76 git config --local --add lfs.access basic
77 # N.B.: "AUTHORIZATION" is not the correct casing, and is therefore the
78 # subject of this test. See lfsapi.Client.extraHeaders() for more.
79 git config --local --add "http.extraHeader" "AUTHORIZATION: $auth"
82 printf "contents" > a.dat
83 git add .gitattributes a.dat
84 git commit -m "initial commit"
86 git push origin master 2>&1 | tee curl.log
87 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
88 echo >&2 "expected \`git push origin master\` to succeed, didn't"
92 [ "0" -eq "$(grep -c "creds: filling with GIT_ASKPASS" curl.log)" ]
93 [ "0" -eq "$(grep -c "creds: git credential approve" curl.log)" ]
94 [ "0" -eq "$(grep -c "creds: git credential cache" curl.log)" ]
95 [ "0" -eq "$(grep -c "creds: git credential fill" curl.log)" ]
96 [ "0" -eq "$(grep -c "creds: git credential reject" curl.log)" ]