Debian Codegraph @

t/t-credentials-no-prompt.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 . "$(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="$(basename "$0" ".sh")"
13 setup_remote_repo "$reponame"
14 clone_repo "$reponame" without-creds
15
16 git lfs track "*.dat"
17 echo "hi" > hi.dat
18 git add hi.dat
19 git add .gitattributes
20 git commit -m "initial commit"
21
22 git config --global credential.helper lfsnoop
23 git config credential.helper lfsnoop
24 git config -l
25
26 GIT_TERMINAL_PROMPT=0 git push origin main 2>&1 | tee push.log
27 grep "Authorization error: $GITSERVER/$reponame" push.log ||
28 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 git lfs track "*.dat"
41 echo "hello" > a.dat
42
43 git add .gitattributes a.dat
44 git commit -m "initial commit"
45
46 git config "credential.helper" ""
47 GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="lfs-askpass-2" SSH_ASKPASS="dont-call-me" GIT_TRACE=1 git push origin main 2>&1 | tee push.log
48 grep "failed to find GIT_ASKPASS command" push.log # attempt askpass
49 grep "creds: git credential fill" push.log # attempt git credential
50 )
51 end_test