From 00823ba386defacebd472ee425cb8ad416102e9c Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 5 Apr 2019 13:24:20 -0400 Subject: [PATCH] vcs-test/vcweb: fix various extraction issues for serving modules with authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • The /auth subdirectory wasn't downloading content from GCS. • The zip extraction logic was failing for zip files that do not contain explicit directory entries. • The invocation of http.FileServer wasn't trimming the /auth prefix, so rejections would work correctly but successful authentication would return 404s instead of serving the file. Updates golang/go#26232 Change-Id: I3a72d7dfca62435c53f4bc7efaebae3900f2c175 Reviewed-on: https://go-review.googlesource.com/c/build/+/170880 Run-TryBot: Bryan C. Mills TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- vcs-test/vcweb/auth.go | 2 +- vcs-test/vcweb/load.go | 4 ++-- vcs-test/vcweb/main.go | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vcs-test/vcweb/auth.go b/vcs-test/vcweb/auth.go index d6ba58d8..09e3237e 100644 --- a/vcs-test/vcweb/auth.go +++ b/vcs-test/vcweb/auth.go @@ -113,5 +113,5 @@ func (h *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - http.FileServer(h.dir).ServeHTTP(w, r) + http.StripPrefix("/auth/", http.FileServer(h.dir)).ServeHTTP(w, r) } diff --git a/vcs-test/vcweb/load.go b/vcs-test/vcweb/load.go index b9aa357e..f4b3d7fe 100644 --- a/vcs-test/vcweb/load.go +++ b/vcs-test/vcweb/load.go @@ -16,7 +16,6 @@ import ( "log" "os" "path/filepath" - "strings" "sync" "time" @@ -119,10 +118,11 @@ func loadFS(dir1, dir2 string, force bool) { check(os.MkdirAll(tmp, 0777)) for _, f := range zr.File { - if strings.HasSuffix(f.Name, "/") { + if f.FileInfo().IsDir() { check(os.MkdirAll(filepath.Join(tmp, f.Name), 0777)) continue } + check(os.MkdirAll(filepath.Join(tmp, filepath.Dir(f.Name)), 0777)) w, err := os.Create(filepath.Join(tmp, f.Name)) check(err) r, err := f.Open() diff --git a/vcs-test/vcweb/main.go b/vcs-test/vcweb/main.go index 4ceafed5..0d5f84c0 100644 --- a/vcs-test/vcweb/main.go +++ b/vcs-test/vcweb/main.go @@ -42,6 +42,7 @@ func usage() { } var isLoadDir = map[string]bool{ + "auth": true, "go": true, "git": true, "hg": true,