]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add test of $GONOPROXY, $GONOSUMDB behavior
authorRuss Cox <rsc@golang.org>
Mon, 29 Apr 2019 12:38:24 +0000 (08:38 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 30 Apr 2019 01:32:48 +0000 (01:32 +0000)
Change-Id: I8a4917ce14ea22d5991226e485d43a9c9312950e
Reviewed-on: https://go-review.googlesource.com/c/go/+/174219
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/script_test.go
src/cmd/go/testdata/script/mod_gonoproxy.txt [new file with mode: 0644]

index 8be7a08675a7806f063337227c4a52f8a022a1cf..499a1ccd3f224528d809f659a4195a5b34d5d930 100644 (file)
@@ -111,6 +111,8 @@ func (ts *testScript) setup() {
                "GOPROXY=" + proxyURL,
                "GOROOT=" + testGOROOT,
                "GOSUMDB=" + testSumDBVerifierKey,
+               "GONOPROXY=",
+               "GONOSUMDB=",
                tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
                "devnull=" + os.DevNull,
                "goversion=" + goVersion(ts),
diff --git a/src/cmd/go/testdata/script/mod_gonoproxy.txt b/src/cmd/go/testdata/script/mod_gonoproxy.txt
new file mode 100644 (file)
index 0000000..f038112
--- /dev/null
@@ -0,0 +1,31 @@
+env GO111MODULE=on
+env sumdb=$GOSUMDB
+env proxy=$GOPROXY
+env GOPROXY GONOPROXY GOSUMDB GONOSUMDB
+env dbname=localhost.localdev/sumdb
+
+# disagree with sumdb fails
+cp go.mod.orig go.mod
+env GOSUMDB=$sumdb' '$proxy/sumdb-wrong
+! go get rsc.io/quote
+stderr 'SECURITY ERROR'
+
+# but GONOSUMDB bypasses sumdb, for rsc.io/quote, rsc.io/sampler, golang.org/x/text
+env GONOSUMDB='*/quote,*/*mple*,golang.org/x'
+go get rsc.io/quote
+
+# and GONOPROXY bypasses proxy
+[!net] skip
+env GONOPROXY='*/fortune'
+! go get rsc.io/fortune # does not exist in real world, only on test proxy
+stderr 'git ls-remote'
+
+env GOSUMDB=
+env GONOPROXY='*/x'
+go get golang.org/x/text
+go list -m all
+! stdout 'text.*v0.0.0-2017' # should not have the version from the proxy
+
+
+-- go.mod.orig --
+module m