| 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 |
|
| 5 |
env GOPROXY=direct |
| 6 |
env 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 |
| 12 |
env NETRC=$WORK/empty |
| 13 |
! go get vcs-test.golang.org/auth/or401 |
| 14 |
stderr '^\tserver response: ACCESS DENIED, buddy$' |
| 15 |
|
| 16 |
# With credentials from a netrc file, it should succeed. |
| 17 |
env NETRC=$WORK/netrc |
| 18 |
go get vcs-test.golang.org/auth/or401 |
| 19 |
|
| 20 |
# GOAUTH=off should result in failures. |
| 21 |
env GOAUTH='off' |
| 22 |
# Without credentials, downloading a module from a path that requires HTTPS |
| 23 |
# basic auth should fail. |
| 24 |
env NETRC=$WORK/empty |
| 25 |
! go get vcs-test.golang.org/auth/or401 |
| 26 |
stderr '^\tserver response: ACCESS DENIED, buddy$' |
| 27 |
|
| 28 |
# GOAUTH='off' should ignore credentials from a valid netrc file. |
| 29 |
env GOAUTH='off' |
| 30 |
env NETRC=$WORK/netrc |
| 31 |
! go get vcs-test.golang.org/auth/or401 |
| 32 |
stderr '^\tserver response: ACCESS DENIED, buddy$' |
| 33 |
|
| 34 |
# GOAUTH=off cannot be combined with other authentication commands |
| 35 |
env GOAUTH='off; netrc' |
| 36 |
env NETRC=$WORK/netrc |
| 37 |
! go get vcs-test.golang.org/auth/or401 |
| 38 |
stderr 'GOAUTH=off cannot be combined with other authentication commands \(GOAUTH=off; netrc\)' |
| 39 |
|
| 40 |
# An unset GOAUTH should default to netrc. |
| 41 |
env GOAUTH= |
| 42 |
# Without credentials, downloading a module from a path that requires HTTPS |
| 43 |
# basic auth should fail. |
| 44 |
env NETRC=$WORK/empty |
| 45 |
! go get vcs-test.golang.org/auth/or401 |
| 46 |
stderr '^\tserver response: ACCESS DENIED, buddy$' |
| 47 |
|
| 48 |
# With credentials from a netrc file, it should succeed. |
| 49 |
env NETRC=$WORK/netrc |
| 50 |
go get vcs-test.golang.org/auth/or401 |
| 51 |
|
| 52 |
# A missing file should be fail as well. |
| 53 |
env NETRC=$WORK/missing |
| 54 |
! go get vcs-test.golang.org/auth/or401 |
| 55 |
stderr '^\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. |
| 60 |
env NETRC= |
| 61 |
env HOME= |
| 62 |
env USERPROFILE= |
| 63 |
env home= |
| 64 |
go 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 -- |
| 70 |
module private.example.com |
| 71 |
-- $WORK/empty -- |
| 72 |
-- $WORK/netrc -- |
| 73 |
machine vcs-test.golang.org |
| 74 |
login aladdin |
| 75 |
password opensesame |
| 76 |
# first one should override this one |
| 77 |
machine vcs-test.golang.org |
| 78 |
login aladdin |
| 79 |
password ignored |