| 1 |
env GO111MODULE=on |
| 2 |
env GOSUMDB=off |
| 3 |
|
| 4 |
go mod download example.com/[email protected] |
| 5 |
|
| 6 |
# If the proxy serves a bogus result for the @latest version, |
| 7 |
# reading that version should cause 'go get' to fail. |
| 8 |
env GOPROXY=file:///$WORK/badproxy |
| 9 |
cp go.mod.orig go.mod |
| 10 |
! go get example.com/join/subpkg |
| 11 |
stderr 'go: example.com/join/[email protected]: .*' |
| 12 |
|
| 13 |
# If @v/list is empty, the 'go' command should still try to resolve |
| 14 |
# other module paths. |
| 15 |
env GOPROXY=file:///$WORK/emptysub |
| 16 |
cp go.mod.orig go.mod |
| 17 |
go get example.com/join/subpkg |
| 18 |
go list -m example.com/join/... |
| 19 |
! stdout 'example.com/join/subpkg' |
| 20 |
stdout 'example.com/join v1.1.0' |
| 21 |
|
| 22 |
# If @v/list includes a version that the proxy does not actually serve, |
| 23 |
# that version is treated as nonexistent. |
| 24 |
env GOPROXY=file:///$WORK/notfound |
| 25 |
cp go.mod.orig go.mod |
| 26 |
go get example.com/join/subpkg |
| 27 |
go list -m example.com/join/... |
| 28 |
! stdout 'example.com/join/subpkg' |
| 29 |
stdout 'example.com/join v1.1.0' |
| 30 |
|
| 31 |
# If the proxy provides an empty @v/list but rejects @latest with |
| 32 |
# some other explicit error (for example, a "permission denied" error), |
| 33 |
# that error should be reported to the user (and override a successful |
| 34 |
# result for other possible module paths). |
| 35 |
# |
| 36 |
# Depending on how the specific platform enforces permissions, the 'go get' may |
| 37 |
# fail either due to the intended permission error or due to a parse error. |
| 38 |
# We accept either failure message. |
| 39 |
env GOPROXY=file:///$WORK/gatekeeper |
| 40 |
chmod 0000 $WORK/gatekeeper/example.com/join/subpkg/@latest |
| 41 |
cp go.mod.orig go.mod |
| 42 |
! go get example.com/join/subpkg |
| 43 |
stderr 'go: module example.com/join/subpkg: (invalid response from proxy ".+": invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)' |
| 44 |
|
| 45 |
-- go.mod.orig -- |
| 46 |
module example.com/othermodule |
| 47 |
go 1.13 |
| 48 |
-- $WORK/badproxy/example.com/join/subpkg/@v/list -- |
| 49 |
v0.0.0-20190624000000-123456abcdef |
| 50 |
-- $WORK/badproxy/example.com/join/subpkg/@v/v0.0.0-20190624000000-123456abcdef.info -- |
| 51 |
This file is not valid JSON. |
| 52 |
-- $WORK/badproxy/example.com/join/@v/list -- |
| 53 |
v1.1.0 |
| 54 |
-- $WORK/badproxy/example.com/join/@v/v1.1.0.info -- |
| 55 |
{"Version": "v1.1.0"} |
| 56 |
-- $WORK/emptysub/example.com/join/subpkg/@v/list -- |
| 57 |
-- $WORK/emptysub/example.com/join/@v/list -- |
| 58 |
v1.1.0 |
| 59 |
-- $WORK/emptysub/example.com/join/@v/v1.1.0.info -- |
| 60 |
{"Version": "v1.1.0"} |
| 61 |
-- $WORK/notfound/example.com/join/subpkg/@v/list -- |
| 62 |
v1.0.0-does-not-exist |
| 63 |
-- $WORK/notfound/example.com/join/@v/list -- |
| 64 |
v1.1.0 |
| 65 |
-- $WORK/notfound/example.com/join/@v/v1.1.0.info -- |
| 66 |
{"Version": "v1.1.0"} |
| 67 |
-- $WORK/gatekeeper/example.com/join/subpkg/@v/list -- |
| 68 |
-- $WORK/gatekeeper/example.com/join/subpkg/@latest -- |
| 69 |
ERROR: Latest version is forbidden. |
| 70 |
-- $WORK/gatekeeper/example.com/join/@v/list -- |
| 71 |
v1.1.0 |
| 72 |
-- $WORK/gatekeeper/example.com/join/@v/v1.1.0.info -- |
| 73 |
{"Version": "v1.1.0"} |