File: t-credentials-no-prompt.sh

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (51 lines) | stat: -rwxr-xr-x 1,403 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash

. "$(dirname "$0")/testlib.sh"

# these tests rely on GIT_TERMINAL_PROMPT to test properly
ensure_git_version_isnt $VERSION_LOWER "2.3.0"

begin_test "attempt private access without credential helper"
(
  set -e

  reponame="$(basename "$0" ".sh")"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" without-creds

  git lfs track "*.dat"
  echo "hi" > hi.dat
  git add hi.dat
  git add .gitattributes
  git commit -m "initial commit"

  git config --global credential.helper lfsnoop
  git config credential.helper lfsnoop
  git config -l

  GIT_TERMINAL_PROMPT=0 git push origin main 2>&1 | tee push.log
  grep "Authorization error: $GITSERVER/$reponame" push.log ||
    grep "Git credentials for $GITSERVER/$reponame not found" push.log
)
end_test

begin_test "askpass: push with bad askpass"
(
  set -e

  reponame="askpass-with-bad-askpass"
  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"

  git config "credential.helper" ""
  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
  grep "failed to find GIT_ASKPASS command" push.log           # attempt askpass
  grep "creds: git credential fill" push.log                   # attempt git credential
)
end_test