Commit 103750f1 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Pass ArchivePrefix from authBackend

parent 4d645003
...@@ -33,10 +33,11 @@ type gitService struct { ...@@ -33,10 +33,11 @@ type gitService struct {
} }
type gitEnv struct { type gitEnv struct {
GL_ID string GL_ID string
RepoPath string RepoPath string
ArchivePath string ArchivePath string
CommitId string ArchivePrefix string
CommitId string
} }
// Routing table // Routing table
...@@ -113,7 +114,7 @@ func (h *gitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -113,7 +114,7 @@ func (h *gitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Negotiate authentication (Kerberos) may need to return a WWW-Authenticate // Negotiate authentication (Kerberos) may need to return a WWW-Authenticate
// header to the client even in case of success as per RFC4559. // header to the client even in case of success as per RFC4559.
for k, v := range authResponse.Header { for k, v := range authResponse.Header {
// Case-insensitive comparison as per RFC7230 // Case-insensitive comparison as per RFC7230
if strings.EqualFold(k, "WWW-Authenticate") { if strings.EqualFold(k, "WWW-Authenticate") {
w.Header()[k] = v w.Header()[k] = v
} }
...@@ -222,9 +223,8 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons ...@@ -222,9 +223,8 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
} }
archiveFilename := path.Base(env.ArchivePath) archiveFilename := path.Base(env.ArchivePath)
archivePrefix := strings.TrimSuffix(archiveFilename, "."+format) + "/"
archiveCmd := gitCommand(env, "git", "--git-dir="+repoPath, "archive", "--format="+archiveFormat, "--prefix="+archivePrefix, env.CommitId) archiveCmd := gitCommand(env, "git", "--git-dir="+repoPath, "archive", "--format="+archiveFormat, "--prefix="+env.ArchivePrefix+"/", env.CommitId)
archiveStdout, err := archiveCmd.StdoutPipe() archiveStdout, err := archiveCmd.StdoutPipe()
if err != nil { if err != nil {
fail500(w, "handleGetArchive", err) fail500(w, "handleGetArchive", err)
......
...@@ -260,7 +260,18 @@ func gitOkBody(t *testing.T) string { ...@@ -260,7 +260,18 @@ func gitOkBody(t *testing.T) string {
} }
func archiveOkBody(t *testing.T, archiveName string) string { func archiveOkBody(t *testing.T, archiveName string) string {
return fmt.Sprintf(`{"RepoPath":"%s","ArchivePath":"/tmp/%s","CommitId":"c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"}`, repoPath(t), archiveName) cwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
archivePath := path.Join(cwd, scratchDir, "cache", archiveName)
jsonString := `{
"RepoPath":"%s",
"ArchivePath":"/tmp/%s",
"CommitId":"c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd",
"ArchivePrefix":"foobar123"
}`
return fmt.Sprintf(jsonString, repoPath(t), archivePath)
} }
func repoPath(t *testing.T) string { func repoPath(t *testing.T) string {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment