Commit ffa068f5 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Rename authorizationResponse to apiResponse

parent 59dc7cdc
......@@ -17,7 +17,7 @@ import (
"time"
)
func handleGetArchive(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
func handleGetArchive(w http.ResponseWriter, r *http.Request, a *apiResponse) {
var format string
urlPath := r.URL.Path
switch filepath.Base(urlPath) {
......
......@@ -5,7 +5,7 @@ import (
)
func (api *API) artifactsAuthorizeHandler(h httpHandleFunc) httpHandleFunc {
return api.preAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
return api.preAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *apiResponse) {
r.Header.Set(tempPathHeader, a.TempPath)
h(w, r)
}, "/authorize")
......
......@@ -86,7 +86,7 @@ func (api *API) preAuthorizeHandler(h serviceHandleFunc, suffix string) httpHand
return
}
a := &authorizationResponse{}
a := &apiResponse{}
// The auth backend validated the client request and told us additional
// request metadata. We must extract this information from the auth
// response body.
......
......@@ -8,14 +8,14 @@ import (
"testing"
)
func okHandler(w http.ResponseWriter, _ *http.Request, _ *authorizationResponse) {
func okHandler(w http.ResponseWriter, _ *http.Request, _ *apiResponse) {
w.WriteHeader(201)
fmt.Fprint(w, "{\"status\":\"ok\"}")
}
func runPreAuthorizeHandler(t *testing.T, suffix string, url *regexp.Regexp, authorizationResponse interface{}, returnCode, expectedCode int) *httptest.ResponseRecorder {
func runPreAuthorizeHandler(t *testing.T, suffix string, url *regexp.Regexp, apiResponse interface{}, returnCode, expectedCode int) *httptest.ResponseRecorder {
// Prepare test server and backend
ts := testAuthServer(url, returnCode, authorizationResponse)
ts := testAuthServer(url, returnCode, apiResponse)
defer ts.Close()
// Create http request
......@@ -35,7 +35,7 @@ func TestPreAuthorizeHappyPath(t *testing.T) {
runPreAuthorizeHandler(
t, "/authorize",
regexp.MustCompile(`/authorize\z`),
&authorizationResponse{},
&apiResponse{},
200, 201)
}
......@@ -43,7 +43,7 @@ func TestPreAuthorizeSuffix(t *testing.T) {
runPreAuthorizeHandler(
t, "/different-authorize",
regexp.MustCompile(`/authorize\z`),
&authorizationResponse{},
&apiResponse{},
200, 404)
}
......
......@@ -27,7 +27,7 @@ func looksLikeRepo(p string) bool {
}
func (api *API) repoPreAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc {
return api.preAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
return api.preAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *apiResponse) {
if a.RepoPath == "" {
fail500(w, errors.New("repoPreAuthorizeHandler: RepoPath empty"))
return
......@@ -42,7 +42,7 @@ func (api *API) repoPreAuthorizeHandler(handleFunc serviceHandleFunc) httpHandle
}, "")
}
func handleGetInfoRefs(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
func handleGetInfoRefs(w http.ResponseWriter, r *http.Request, a *apiResponse) {
rpc := r.URL.Query().Get("service")
if !(rpc == "git-upload-pack" || rpc == "git-receive-pack") {
// The 'dumb' Git HTTP protocol is not supported
......@@ -86,7 +86,7 @@ func handleGetInfoRefs(w http.ResponseWriter, r *http.Request, a *authorizationR
}
}
func handlePostRPC(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
func handlePostRPC(w http.ResponseWriter, r *http.Request, a *apiResponse) {
var err error
// Get Git action from URL
......
......@@ -18,7 +18,7 @@ import (
)
func (api *API) lfsAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc {
return api.preAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
return api.preAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *apiResponse) {
if a.StoreLFSPath == "" {
fail500(w, errors.New("lfsAuthorizeHandler: StoreLFSPath empty"))
......@@ -39,7 +39,7 @@ func (api *API) lfsAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc
}, "/authorize")
}
func (u *upstream) handleStoreLfsObject(w http.ResponseWriter, r *http.Request, a *authorizationResponse) {
func (u *upstream) handleStoreLfsObject(w http.ResponseWriter, r *http.Request, a *apiResponse) {
file, err := ioutil.TempFile(a.StoreLFSPath, a.LfsOid)
if err != nil {
fail500(w, fmt.Errorf("handleStoreLfsObject: create tempfile: %v", err))
......
......@@ -340,7 +340,7 @@ func runOrFail(t *testing.T, cmd *exec.Cmd) {
}
func gitOkBody(t *testing.T) interface{} {
return &authorizationResponse{
return &apiResponse{
GL_ID: "user-123",
RepoPath: repoPath(t),
}
......@@ -353,7 +353,7 @@ func archiveOkBody(t *testing.T, archiveName string) interface{} {
}
archivePath := path.Join(cwd, cacheDir, archiveName)
return &authorizationResponse{
return &apiResponse{
RepoPath: repoPath(t),
ArchivePath: archivePath,
CommitId: "c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd",
......
......@@ -15,7 +15,7 @@ import (
"strings"
)
type serviceHandleFunc func(http.ResponseWriter, *http.Request, *authorizationResponse)
type serviceHandleFunc func(http.ResponseWriter, *http.Request, *apiResponse)
type API struct {
*http.Client
......@@ -29,7 +29,7 @@ type upstream struct {
relativeURLRoot string
}
type authorizationResponse struct {
type apiResponse struct {
// GL_ID is an environment variable used by gitlab-shell hooks during 'git
// push' and 'git pull'
GL_ID 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