...
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
7env GOPROXY=direct
8env GOSUMDB=off
9# Disable 'git credential fill' interactive prompts.
10env GIT_TERMINAL_PROMPT=0
11exec git init
12exec git config credential.helper 'store --file=.git-credentials'
13cp go.mod.orig go.mod
14
15# Set GOAUTH to git without a working directory.
16env GOAUTH='git'
17! go get vcs-test.golang.org/auth/or401
18stderr 'GOAUTH=git dir method requires an absolute path to the git working directory'
19
20# Set GOAUTH to git with a non-existent directory.
21env GOAUTH='git gitDir'
22! go get vcs-test.golang.org/auth/or401
23stderr 'GOAUTH=git dir method requires an absolute path to the git working directory'
24
25# Set GOAUTH to git with a relative working directory.
26mkdir relative
27env GOAUTH='git relative'
28! go get vcs-test.golang.org/auth/or401
29stderr '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.
34env GOAUTH=git' '$PWD''
35! go get -x vcs-test.golang.org/auth/or401
36stderr '^\tserver response: ACCESS DENIED, buddy$'
37stderr 'GOAUTH encountered errors for https://vcs-test.golang.org'
38stderr GOAUTH=git' '$PWD''
39# go imports should fail as well.
40! go mod tidy -x
41stderr '^\tserver response: File\? What file\?$'
42stderr 'GOAUTH encountered errors for https://vcs-test.golang.org'
43stderr GOAUTH=git' '$PWD''
44
45# With credentials from git credentials, it should succeed.
46cp .git-credentials.cred .git-credentials
47go get vcs-test.golang.org/auth/or401
48# go imports should resolve correctly as well.
49go mod tidy
50go list all
51stdout vcs-test.golang.org/auth/or404
52
53# Clearing GOAUTH credentials should result in failures.
54env 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
58stderr '^\tserver response: ACCESS DENIED, buddy$'
59# go imports should fail as well.
60cp go.mod.orig go.mod
61! go mod tidy
62stderr '^\tserver response: File\? What file\?$'
63
64-- main.go --
65package useprivate
66
67import "vcs-test.golang.org/auth/or404"
68-- go.mod.orig --
69module private.example.com
70-- .git-credentials --
71-- .git-credentials.cred --
72https://aladdin:opensesame@vcs-test.golang.org
View as plain text