2017-08-10 22:30:42 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2017-08-10 22:30:42 +00:00
|
|
|
|
|
|
|
begin_test "askpass: push with GIT_ASKPASS"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2017-09-22 17:45:10 +00:00
|
|
|
reponame="askpass-with-git-environ"
|
2017-08-10 22:30:42 +00:00
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "hello" > a.dat
|
|
|
|
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
# $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
|
2017-09-13 22:09:18 +00:00
|
|
|
export LFS_ASKPASS_USERNAME="user"
|
2017-09-13 16:15:45 +00:00
|
|
|
export LFS_ASKPASS_PASSWORD="pass"
|
2017-10-02 17:57:07 +00:00
|
|
|
git config "credential.helper" ""
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_ASKPASS="lfs-askpass" SSH_ASKPASS="dont-call-me" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin main 2>&1 | tee push.log
|
2017-08-10 22:30:42 +00:00
|
|
|
|
2017-09-13 22:09:18 +00:00
|
|
|
GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
|
|
|
|
|
|
|
|
grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
|
|
|
|
grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main -> main" push.log
|
2017-08-10 22:30:42 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2017-08-11 17:02:10 +00:00
|
|
|
begin_test "askpass: push with core.askPass"
|
2017-08-10 22:30:42 +00:00
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2017-08-11 17:55:41 +00:00
|
|
|
if [ ! -z "$TRAVIS" ] ; then
|
|
|
|
# This test is known to be broken on Travis, so we skip it if the $TRAVIS
|
|
|
|
# environment variable is set.
|
|
|
|
#
|
|
|
|
# See: https://github.com/git-lfs/git-lfs/pull/2500 for more.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-08-10 22:30:42 +00:00
|
|
|
reponame="askpass-with-config"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "hello" > a.dat
|
|
|
|
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
# $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
|
2017-09-13 16:15:45 +00:00
|
|
|
export LFS_ASKPASS_PASSWORD="pass"
|
2017-10-02 17:57:07 +00:00
|
|
|
git config "credential.helper" ""
|
2017-09-13 16:15:45 +00:00
|
|
|
git config "core.askPass" "lfs-askpass"
|
2017-08-10 22:30:42 +00:00
|
|
|
cat .git/config
|
2020-06-29 16:18:57 +00:00
|
|
|
SSH_ASKPASS="dont-call-me" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin main 2>&1 | tee push.log
|
2017-09-22 17:45:10 +00:00
|
|
|
|
|
|
|
GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
|
|
|
|
|
|
|
|
grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
|
|
|
|
grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main -> main" push.log
|
2017-09-22 17:45:10 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "askpass: push with SSH_ASKPASS"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2017-09-26 17:26:57 +00:00
|
|
|
if [ ! -z "$TRAVIS" ] ; then
|
|
|
|
# This test is known to be broken on Travis, so we skip it if the $TRAVIS
|
|
|
|
# environment variable is set.
|
|
|
|
#
|
|
|
|
# See: https://github.com/git-lfs/git-lfs/pull/2500 for more.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-09-22 17:45:10 +00:00
|
|
|
reponame="askpass-with-ssh-environ"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "hello" > a.dat
|
|
|
|
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
# $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
|
|
|
|
export LFS_ASKPASS_USERNAME="user"
|
|
|
|
export LFS_ASKPASS_PASSWORD="pass"
|
2017-10-02 17:57:07 +00:00
|
|
|
git config "credential.helper" ""
|
2020-06-29 16:18:57 +00:00
|
|
|
SSH_ASKPASS="lfs-askpass" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin main 2>&1 | tee push.log
|
2017-08-10 22:30:42 +00:00
|
|
|
|
2017-09-13 22:09:18 +00:00
|
|
|
GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
|
|
|
|
|
|
|
|
grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
|
|
|
|
grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main -> main" push.log
|
2017-08-10 22:30:42 +00:00
|
|
|
)
|
|
|
|
end_test
|
2018-07-13 22:11:04 +00:00
|
|
|
|
|
|
|
begin_test "askpass: defaults to provided credentials"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="askpass-provided-creds"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "hello" > a.dat
|
|
|
|
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
# $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
|
|
|
|
export LFS_ASKPASS_USERNAME="fakeuser"
|
|
|
|
export LFS_ASKPASS_PASSWORD="fakepass"
|
2018-07-13 23:51:00 +00:00
|
|
|
git config --local "credential.helper" ""
|
2018-07-13 22:11:04 +00:00
|
|
|
|
|
|
|
url=$(git config --get remote.origin.url)
|
|
|
|
newurl=${url/http:\/\//http:\/\/user\:pass@}
|
|
|
|
git remote set-url origin "$newurl"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_ASKPASS="lfs-askpass" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin main 2>&1 | tee push.log
|
2018-07-13 22:11:04 +00:00
|
|
|
|
|
|
|
[ ! $(grep "filling with GIT_ASKPASS" push.log) ]
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main -> main" push.log
|
2018-07-13 22:11:04 +00:00
|
|
|
)
|
|
|
|
end_test
|