mirror of
https://github.com/golang/go
synced 2024-11-23 20:20:01 -07:00
cmd/go: fix module get -insecure
Need to actually use the flag for it to take effect. Fixes #27049. Change-Id: I57227b45f46f9dd67ecbf87c11bb2d08124bcfa0 Reviewed-on: https://go-review.googlesource.com/129801 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
c5046bca7b
commit
bf80e3b564
@ -3532,24 +3532,43 @@ func TestImportLocal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGoGetInsecure(t *testing.T) {
|
func TestGoGetInsecure(t *testing.T) {
|
||||||
testenv.MustHaveExternalNetwork(t)
|
test := func(t *testing.T, modules bool) {
|
||||||
|
testenv.MustHaveExternalNetwork(t)
|
||||||
|
|
||||||
tg := testgo(t)
|
tg := testgo(t)
|
||||||
defer tg.cleanup()
|
defer tg.cleanup()
|
||||||
tg.makeTempdir()
|
tg.makeTempdir()
|
||||||
tg.setenv("GOPATH", tg.path("."))
|
tg.failSSH()
|
||||||
tg.failSSH()
|
|
||||||
|
|
||||||
const repo = "insecure.go-get-issue-15410.appspot.com/pkg/p"
|
if modules {
|
||||||
|
tg.setenv("GOPATH", tg.path("gp"))
|
||||||
|
tg.tempFile("go.mod", "module m")
|
||||||
|
tg.cd(tg.path("."))
|
||||||
|
tg.setenv("GO111MODULE", "on")
|
||||||
|
} else {
|
||||||
|
tg.setenv("GOPATH", tg.path("."))
|
||||||
|
tg.setenv("GO111MODULE", "off")
|
||||||
|
}
|
||||||
|
|
||||||
// Try go get -d of HTTP-only repo (should fail).
|
const repo = "insecure.go-get-issue-15410.appspot.com/pkg/p"
|
||||||
tg.runFail("get", "-d", repo)
|
|
||||||
|
|
||||||
// Try again with -insecure (should succeed).
|
// Try go get -d of HTTP-only repo (should fail).
|
||||||
tg.run("get", "-d", "-insecure", repo)
|
tg.runFail("get", "-d", repo)
|
||||||
|
|
||||||
// Try updating without -insecure (should fail).
|
// Try again with -insecure (should succeed).
|
||||||
tg.runFail("get", "-d", "-u", "-f", repo)
|
tg.run("get", "-d", "-insecure", repo)
|
||||||
|
|
||||||
|
// Try updating without -insecure (should fail).
|
||||||
|
tg.runFail("get", "-d", "-u", "-f", repo)
|
||||||
|
|
||||||
|
if modules {
|
||||||
|
tg.run("list", "-m", "...")
|
||||||
|
tg.grepStdout("insecure.go-get-issue", "should find insecure module")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("gopath", func(t *testing.T) { test(t, false) })
|
||||||
|
t.Run("modules", func(t *testing.T) { test(t, true) })
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGoGetUpdateInsecure(t *testing.T) {
|
func TestGoGetUpdateInsecure(t *testing.T) {
|
||||||
|
@ -216,7 +216,11 @@ func lookup(path string) (r Repo, err error) {
|
|||||||
return lookupProxy(path)
|
return lookupProxy(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
rr, err := get.RepoRootForImportPath(path, get.PreferMod, web.Secure)
|
security := web.Secure
|
||||||
|
if get.Insecure {
|
||||||
|
security = web.Insecure
|
||||||
|
}
|
||||||
|
rr, err := get.RepoRootForImportPath(path, get.PreferMod, security)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// We don't know where to find code for a module with this path.
|
// We don't know where to find code for a module with this path.
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -257,7 +261,11 @@ func ImportRepoRev(path, rev string) (Repo, *RevInfo, error) {
|
|||||||
// Note: Because we are converting a code reference from a legacy
|
// Note: Because we are converting a code reference from a legacy
|
||||||
// version control system, we ignore meta tags about modules
|
// version control system, we ignore meta tags about modules
|
||||||
// and use only direct source control entries (get.IgnoreMod).
|
// and use only direct source control entries (get.IgnoreMod).
|
||||||
rr, err := get.RepoRootForImportPath(path, get.IgnoreMod, web.Secure)
|
security := web.Secure
|
||||||
|
if get.Insecure {
|
||||||
|
security = web.Insecure
|
||||||
|
}
|
||||||
|
rr, err := get.RepoRootForImportPath(path, get.IgnoreMod, security)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user