| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 4 | |
| 5 | # these tests rely on GIT_TERMINAL_PROMPT to test properly |
| 6 | ensure_git_version_isnt $VERSION_LOWER "2.3.0" |
| 7 | |
| 8 | begin_test "attempt private access without credential helper" |
| 9 | ( |
| 10 | set -e |
| 11 | |
| 12 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")" |
| 13 | setup_remote_repo "$reponame" |
| 14 | clone_repo "$reponame" without-creds |
| 15 | |
| 16 | gitscip-shell system . . git. lfs track "*.dat" |
| 17 | echoscip-shell system . . echo. "hi" > hi.dat |
| 18 | gitscip-shell system . . git. add hi.dat |
| 19 | gitscip-shell system . . git. add .gitattributes |
| 20 | gitscip-shell system . . git. commit -m "initial commit" |
| 21 | |
| 22 | gitscip-shell system . . git. config --global credential.helper lfsnoop |
| 23 | gitscip-shell system . . git. config credential.helper lfsnoop |
| 24 | gitscip-shell system . . git. config -l |
| 25 | |
| 26 | GIT_TERMINAL_PROMPT=0 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log |
| 27 | grepscip-shell system . . grep. "Authorization error: $GITSERVER/$reponame" push.log || |
| 28 | grepscip-shell system . . grep. "Git credentials for $GITSERVER/$reponame not found" push.log |
| 29 | ) |
| 30 | end_test |
| 31 | |
| 32 | begin_test "askpass: push with bad askpass" |
| 33 | ( |
| 34 | set -e |
| 35 | |
| 36 | reponame="askpass-with-bad-askpass" |
| 37 | setup_remote_repo "$reponame" |
| 38 | clone_repo "$reponame" "$reponame" |
| 39 | |
| 40 | gitscip-shell system . . git. lfs track "*.dat" |
| 41 | echoscip-shell system . . echo. "hello" > a.dat |
| 42 | |
| 43 | gitscip-shell system . . git. add .gitattributes a.dat |
| 44 | gitscip-shell system . . git. commit -m "initial commit" |
| 45 | |
| 46 | gitscip-shell system . . git. config "credential.helper" "" |
| 47 | GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="lfs-askpass-2" SSH_ASKPASS="dont-call-me" GIT_TRACE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log |
| 48 | grepscip-shell system . . grep. "failed to find GIT_ASKPASS command" push.log # attempt askpass |
| 49 | grepscip-shell system . . grep. "creds: git credential fill" push.log # attempt git credential |
| 50 | ) |
| 51 | end_test |