3 . "$(dirname "$0")/testlib.sh"
5 begin_test "askpass: push with GIT_ASKPASS"
9 reponame="askpass-with-git-environ"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
16 git add .gitattributes a.dat
17 git commit -m "initial commit"
19 # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
20 export LFS_ASKPASS_USERNAME="user"
21 export LFS_ASKPASS_PASSWORD="pass"
22 git config "credential.helper" ""
23 GIT_ASKPASS="lfs-askpass" SSH_ASKPASS="dont-call-me" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
25 GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
27 grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
28 grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
29 grep "master -> master" push.log
33 begin_test "askpass: push with core.askPass"
37 if [ ! -z "$TRAVIS" ] ; then
38 # This test is known to be broken on Travis, so we skip it if the $TRAVIS
39 # environment variable is set.
41 # See: https://github.com/git-lfs/git-lfs/pull/2500 for more.
45 reponame="askpass-with-config"
46 setup_remote_repo "$reponame"
47 clone_repo "$reponame" "$reponame"
52 git add .gitattributes a.dat
53 git commit -m "initial commit"
55 # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
56 export LFS_ASKPASS_PASSWORD="pass"
57 git config "credential.helper" ""
58 git config "core.askPass" "lfs-askpass"
60 SSH_ASKPASS="dont-call-me" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
62 GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
64 grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
65 grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
66 grep "master -> master" push.log
70 begin_test "askpass: push with SSH_ASKPASS"
74 if [ ! -z "$TRAVIS" ] ; then
75 # This test is known to be broken on Travis, so we skip it if the $TRAVIS
76 # environment variable is set.
78 # See: https://github.com/git-lfs/git-lfs/pull/2500 for more.
82 reponame="askpass-with-ssh-environ"
83 setup_remote_repo "$reponame"
84 clone_repo "$reponame" "$reponame"
89 git add .gitattributes a.dat
90 git commit -m "initial commit"
92 # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
93 export LFS_ASKPASS_USERNAME="user"
94 export LFS_ASKPASS_PASSWORD="pass"
95 git config "credential.helper" ""
96 SSH_ASKPASS="lfs-askpass" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
98 GITSERVER_USER="$(printf $GITSERVER | sed -e 's/http:\/\//http:\/\/user@/')"
100 grep "filling with GIT_ASKPASS: lfs-askpass Username for \"$GITSERVER/$reponame\"" push.log
101 grep "filling with GIT_ASKPASS: lfs-askpass Password for \"$GITSERVER_USER/$reponame\"" push.log
102 grep "master -> master" push.log
106 begin_test "askpass: defaults to provided credentials"
110 reponame="askpass-provided-creds"
111 setup_remote_repo "$reponame"
112 clone_repo "$reponame" "$reponame"
114 git lfs track "*.dat"
117 git add .gitattributes a.dat
118 git commit -m "initial commit"
120 # $password is defined from test/cmd/lfstest-gitserver.go (see: skipIfBadAuth)
121 export LFS_ASKPASS_USERNAME="fakeuser"
122 export LFS_ASKPASS_PASSWORD="fakepass"
123 git config --local "credential.helper" ""
125 url=$(git config --get remote.origin.url)
126 newurl=${url/http:\/\//http:\/\/user\:pass@}
127 git remote set-url origin "$newurl"
129 GIT_ASKPASS="lfs-askpass" GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
131 [ ! $(grep "filling with GIT_ASKPASS" push.log) ]
132 grep "master -> master" push.log