vcs-test/vcweb: fix various extraction issues for serving modules with authentication
• 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 <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
diff --git a/vcs-test/vcweb/auth.go b/vcs-test/vcweb/auth.go
index d6ba58d..09e3237 100644
--- a/vcs-test/vcweb/auth.go
+++ b/vcs-test/vcweb/auth.go
@@ -113,5 +113,5 @@
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 b9aa357..f4b3d7f 100644
--- a/vcs-test/vcweb/load.go
+++ b/vcs-test/vcweb/load.go
@@ -16,7 +16,6 @@
"log"
"os"
"path/filepath"
- "strings"
"sync"
"time"
@@ -119,10 +118,11 @@
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 4ceafed..0d5f84c 100644
--- a/vcs-test/vcweb/main.go
+++ b/vcs-test/vcweb/main.go
@@ -42,6 +42,7 @@
}
var isLoadDir = map[string]bool{
+ "auth": true,
"go": true,
"git": true,
"hg": true,