| 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 |
# With cached credentials, re-downloading in debug mode should succeed. |
| 53 |
go get -x vcs-test.golang.org/auth/or401 |
| 54 |
|
| 55 |
# Clearing GOAUTH credentials should result in failures. |
| 56 |
env GOAUTH='off' |
| 57 |
# Without credentials, downloading a module from a path that requires HTTPS |
| 58 |
# basic auth should fail. |
| 59 |
! go get vcs-test.golang.org/auth/or401 |
| 60 |
stderr '^\tserver response: ACCESS DENIED, buddy$' |
| 61 |
# go imports should fail as well. |
| 62 |
cp go.mod.orig go.mod |
| 63 |
! go mod tidy |
| 64 |
stderr '^\tserver response: File\? What file\?$' |
| 65 |
|
| 66 |
-- main.go -- |
| 67 |
package useprivate |
| 68 |
|
| 69 |
import "vcs-test.golang.org/auth/or404" |
| 70 |
-- go.mod.orig -- |
| 71 |
module private.example.com |
| 72 |
-- .git-credentials -- |
| 73 |
-- .git-credentials.cred -- |
| 74 |
https://aladdin:[email protected] |