summaryrefslogtreecommitdiff
path: root/libgo/go/cmd/go/proxy_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/cmd/go/proxy_test.go')
-rw-r--r--libgo/go/cmd/go/proxy_test.go42
1 files changed, 24 insertions, 18 deletions
diff --git a/libgo/go/cmd/go/proxy_test.go b/libgo/go/cmd/go/proxy_test.go
index 6919d321847..8214488a59a 100644
--- a/libgo/go/cmd/go/proxy_test.go
+++ b/libgo/go/cmd/go/proxy_test.go
@@ -23,14 +23,15 @@ import (
"sync"
"testing"
- "cmd/go/internal/dirhash"
"cmd/go/internal/modfetch"
"cmd/go/internal/modfetch/codehost"
- "cmd/go/internal/module"
"cmd/go/internal/par"
- "cmd/go/internal/semver"
- "cmd/go/internal/sumweb"
"cmd/go/internal/txtar"
+
+ "golang.org/x/mod/module"
+ "golang.org/x/mod/semver"
+ "golang.org/x/mod/sumdb"
+ "golang.org/x/mod/sumdb/dirhash"
)
var (
@@ -65,7 +66,7 @@ func StartProxy() {
// Prepopulate main sumdb.
for _, mod := range modList {
- sumdbHandler.Server.Lookup(nil, mod.Path+"@"+mod.Version)
+ sumdbOps.Lookup(nil, mod)
}
})
}
@@ -88,7 +89,7 @@ func readModList() {
continue
}
encPath := strings.ReplaceAll(name[:i], "_", "/")
- path, err := module.DecodePath(encPath)
+ path, err := module.UnescapePath(encPath)
if err != nil {
if encPath != "example.com/invalidpath/v1" {
fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
@@ -96,7 +97,7 @@ func readModList() {
continue
}
encVers := name[i+1:]
- vers, err := module.DecodeVersion(encVers)
+ vers, err := module.UnescapeVersion(encVers)
if err != nil {
fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
continue
@@ -113,8 +114,13 @@ const (
testSumDBSignerKey = "PRIVATE+KEY+localhost.localdev/sumdb+00000c67+AXu6+oaVaOYuQOFrf1V59JK1owcFlJcHwwXHDfDGxSPk"
)
-var sumdbHandler = &sumweb.Handler{Server: sumweb.NewTestServer(testSumDBSignerKey, proxyGoSum)}
-var sumdbWrongHandler = &sumweb.Handler{Server: sumweb.NewTestServer(testSumDBSignerKey, proxyGoSumWrong)}
+var (
+ sumdbOps = sumdb.NewTestServer(testSumDBSignerKey, proxyGoSum)
+ sumdbServer = sumdb.NewServer(sumdbOps)
+
+ sumdbWrongOps = sumdb.NewTestServer(testSumDBSignerKey, proxyGoSumWrong)
+ sumdbWrongServer = sumdb.NewServer(sumdbWrongOps)
+)
// proxyHandler serves the Go module proxy protocol.
// See the proxy section of https://research.swtch.com/vgo-module.
@@ -155,7 +161,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
// (Client thinks it is talking directly to a sumdb.)
if strings.HasPrefix(path, "sumdb-direct/") {
r.URL.Path = path[len("sumdb-direct"):]
- sumdbHandler.ServeHTTP(w, r)
+ sumdbServer.ServeHTTP(w, r)
return
}
@@ -164,7 +170,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
// (Client thinks it is talking directly to a sumdb.)
if strings.HasPrefix(path, "sumdb-wrong/") {
r.URL.Path = path[len("sumdb-wrong"):]
- sumdbWrongHandler.ServeHTTP(w, r)
+ sumdbWrongServer.ServeHTTP(w, r)
return
}
@@ -178,7 +184,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
// Request for $GOPROXY/sumdb/<name>/... goes to sumdb.
if sumdbPrefix := "sumdb/" + testSumDBName + "/"; strings.HasPrefix(path, sumdbPrefix) {
r.URL.Path = path[len(sumdbPrefix)-1:]
- sumdbHandler.ServeHTTP(w, r)
+ sumdbServer.ServeHTTP(w, r)
return
}
@@ -187,7 +193,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
// latest version, including pseudo-versions.
if i := strings.LastIndex(path, "/@latest"); i >= 0 {
enc := path[:i]
- modPath, err := module.DecodePath(enc)
+ modPath, err := module.UnescapePath(enc)
if err != nil {
if !quiet {
fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
@@ -225,7 +231,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
return
}
- encVers, err := module.EncodeVersion(latest)
+ encVers, err := module.EscapeVersion(latest)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -240,7 +246,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
return
}
enc, file := path[:i], path[i+len("/@v/"):]
- path, err := module.DecodePath(enc)
+ path, err := module.UnescapePath(enc)
if err != nil {
if !quiet {
fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
@@ -276,7 +282,7 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
return
}
encVers, ext := file[:i], file[i+1:]
- vers, err := module.DecodeVersion(encVers)
+ vers, err := module.UnescapeVersion(encVers)
if err != nil {
fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
http.NotFound(w, r)
@@ -397,11 +403,11 @@ var archiveCache par.Cache
var cmdGoDir, _ = os.Getwd()
func readArchive(path, vers string) (*txtar.Archive, error) {
- enc, err := module.EncodePath(path)
+ enc, err := module.EscapePath(path)
if err != nil {
return nil, err
}
- encVers, err := module.EncodeVersion(vers)
+ encVers, err := module.EscapeVersion(vers)
if err != nil {
return nil, err
}