github.com/ungtb10d/git-lfs@v2.5.2+incompatible/t/t-extra-header.sh (about) 1 #!/usr/bin/env bash 2 3 . "$(dirname "$0")/testlib.sh" 4 5 begin_test "http.<url>.extraHeader" 6 ( 7 set -e 8 9 reponame="copy-headers" 10 setup_remote_repo "$reponame" 11 clone_repo "$reponame" "$reponame" 12 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" 16 17 git lfs track "*.dat" 18 printf "contents" > a.dat 19 git add .gitattributes a.dat 20 git commit -m "initial commit" 21 22 GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push origin master 2>&1 | tee curl.log 23 24 grep "> X-Foo: bar" curl.log 25 grep "> X-Foo: baz" curl.log 26 ) 27 end_test 28 29 begin_test "http.<url>.extraHeader with authorization" 30 ( 31 set -e 32 33 reponame="requirecreds-extraHeader" 34 setup_remote_repo "$reponame" 35 clone_repo "$reponame" "$reponame" 36 37 # See: test/cmd/lfstest-gitserver.go:missingRequiredCreds(). 38 user="requirecreds" 39 pass="pass" 40 auth="Basic $(echo -n $user:$pass | base64)" 41 42 git config --add "http.extraHeader" "Authorization: $auth" 43 44 git lfs track "*.dat" 45 printf "contents" > a.dat 46 git add .gitattributes a.dat 47 git commit -m "initial commit" 48 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" 52 exit 1 53 fi 54 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)" ] 60 ) 61 end_test 62 63 begin_test "http.<url>.extraHeader with authorization (casing)" 64 ( 65 set -e 66 67 reponame="requirecreds-extraHeaderCasing" 68 setup_remote_repo "$reponame" 69 clone_repo "$reponame" "$reponame" 70 71 # See: test/cmd/lfstest-gitserver.go:missingRequiredCreds(). 72 user="requirecreds" 73 pass="pass" 74 auth="Basic $(echo -n $user:$pass | base64)" 75 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" 80 81 git lfs track "*.dat" 82 printf "contents" > a.dat 83 git add .gitattributes a.dat 84 git commit -m "initial commit" 85 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" 89 exit 1 90 fi 91 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)" ] 97 ) 98 end_test