1 # This test covers the HTTP authentication mechanism over GOAUTH
2 # See golang.org/issue/26232
3
4 [!git] skip
5
6 env GOPROXY=direct
7 env GOSUMDB=off
8 # Disable 'git credential fill' interactive prompts.
9 env GIT_TERMINAL_PROMPT=0
10 exec git init
11 # Ignore credential helpers inherited from system configuration.
12 exec git config credential.helper ''
13 exec git config --add credential.helper 'store --file=.git-credentials'
14 cp go.mod.orig go.mod
15
16 # Set GOAUTH to git without a working directory.
17 env GOAUTH='git'
18 ! go get vcs-test.golang.org/auth/or401
19 stderr 'GOAUTH=git dir method requires an absolute path to the git working directory'
20
21 # Set GOAUTH to git with a non-existent directory.
22 env GOAUTH='git gitDir'
23 ! go get vcs-test.golang.org/auth/or401
24 stderr 'GOAUTH=git dir method requires an absolute path to the git working directory'
25
26 # Set GOAUTH to git with a relative working directory.
27 mkdir relative
28 env GOAUTH='git relative'
29 ! go get vcs-test.golang.org/auth/or401
30 stderr 'GOAUTH=git dir method requires an absolute path to the git working directory'
31
32 # Set GOAUTH to git and use a blank .git-credentials.
33 # Without credentials, downloading a module from a path that requires HTTPS
34 # basic auth should fail.
35 env GOAUTH=git' '$PWD''
36 ! go get -x vcs-test.golang.org/auth/or401
37 stderr '^\tserver response: ACCESS DENIED, buddy$'
38 stderr 'GOAUTH encountered errors for https://vcs-test.golang.org'
39 stderr GOAUTH=git' '$PWD''
40 # go imports should fail as well.
41 ! go mod tidy -x
42 stderr '^\tserver response: File\? What file\?$'
43 stderr 'GOAUTH encountered errors for https://vcs-test.golang.org'
44 stderr GOAUTH=git' '$PWD''
45
46 # With credentials from git credentials, it should succeed.
47 cp .git-credentials.cred .git-credentials
48 go get vcs-test.golang.org/auth/or401
49 # go imports should resolve correctly as well.
50 go mod tidy
51 go list all
52 stdout vcs-test.golang.org/auth/or404
53 # With cached credentials, re-downloading in debug mode should succeed.
54 go get -x vcs-test.golang.org/auth/or401
55
56 # Clearing GOAUTH credentials should result in failures.
57 env GOAUTH='off'
58 # Without credentials, downloading a module from a path that requires HTTPS
59 # basic auth should fail.
60 ! go get vcs-test.golang.org/auth/or401
61 stderr '^\tserver response: ACCESS DENIED, buddy$'
62 # go imports should fail as well.
63 cp go.mod.orig go.mod
64 ! go mod tidy
65 stderr '^\tserver response: File\? What file\?$'
66
67 -- main.go --
68 package useprivate
69
70 import "vcs-test.golang.org/auth/or404"
71 -- go.mod.orig --
72 module private.example.com
73 -- .git-credentials --
74 -- .git-credentials.cred --
75 https://aladdin:opensesame@vcs-test.golang.org
76
View as plain text