...
1# This test exercises the GOAUTH mechanism for specifying
2# credentials passed in HTTPS requests to VCS servers.
3# See golang.org/issue/26232
4
5env GOPROXY=direct
6env GOSUMDB=off
7
8# GOAUTH should default to netrc behavior.
9# Without credentials, downloading a module from a path that requires HTTPS
10# basic auth should fail.
11# Override default location of $HOME/.netrc
12env NETRC=$WORK/empty
13! go get vcs-test.golang.org/auth/or401
14stderr '^\tserver response: ACCESS DENIED, buddy$'
15
16# With credentials from a netrc file, it should succeed.
17env NETRC=$WORK/netrc
18go get vcs-test.golang.org/auth/or401
19
20# GOAUTH=off should result in failures.
21env GOAUTH='off'
22# Without credentials, downloading a module from a path that requires HTTPS
23# basic auth should fail.
24env NETRC=$WORK/empty
25! go get vcs-test.golang.org/auth/or401
26stderr '^\tserver response: ACCESS DENIED, buddy$'
27
28# GOAUTH='off' should ignore credentials from a valid netrc file.
29env GOAUTH='off'
30env NETRC=$WORK/netrc
31! go get vcs-test.golang.org/auth/or401
32stderr '^\tserver response: ACCESS DENIED, buddy$'
33
34# GOAUTH=off cannot be combined with other authentication commands
35env GOAUTH='off; netrc'
36env NETRC=$WORK/netrc
37! go get vcs-test.golang.org/auth/or401
38stderr 'GOAUTH=off cannot be combined with other authentication commands \(GOAUTH=off; netrc\)'
39
40# An unset GOAUTH should default to netrc.
41env GOAUTH=
42# Without credentials, downloading a module from a path that requires HTTPS
43# basic auth should fail.
44env NETRC=$WORK/empty
45! go get vcs-test.golang.org/auth/or401
46stderr '^\tserver response: ACCESS DENIED, buddy$'
47
48# With credentials from a netrc file, it should succeed.
49env NETRC=$WORK/netrc
50go get vcs-test.golang.org/auth/or401
51
52# A missing file should be fail as well.
53env NETRC=$WORK/missing
54! go get vcs-test.golang.org/auth/or401
55stderr '^\tserver response: ACCESS DENIED, buddy$'
56
57[short] skip 'requires a remote vcs lookup'
58[!git] skip
59# An unset home directory should warn the user but not cause a failure.
60env NETRC=
61env HOME=
62env USERPROFILE=
63env home=
64go get -x vcs-test.golang.org/git/emptytest.git
65[!GOOS:windows] [!GOOS:plan9] stderr 'GOAUTH=netrc: \$HOME is not defined'
66[GOOS:windows] stderr 'GOAUTH=netrc: \%userprofile\% is not defined'
67[GOOS:plan9] stderr 'GOAUTH=netrc: \$home is not defined'
68
69-- go.mod --
70module private.example.com
71-- $WORK/empty --
72-- $WORK/netrc --
73machine vcs-test.golang.org
74 login aladdin
75 password opensesame
76# first one should override this one
77machine vcs-test.golang.org
78 login aladdin
79 password ignored
View as plain text