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