diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2020-11-26 17:59:32 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2020-11-29 19:28:43 +0300 |
commit | e2599b42db123fdf17cf141f39396fc12004222d (patch) | |
tree | 45e0905cedd288fbd424154068cab38610463f2a /internal/testhelper | |
parent | 8ea1e30f3bca48776c822f22235857c7dd41d528 (diff) |
gitaly-hooks check: check is not a gitaly hook
'check' subcommand is not a real hook and should not write to the
same log used by actual gitaly-hook subcommands.
The 'GitlabNetClient.Check' method of the gitlab-shell lib expects
to get a JSON with 'message' field in case of an error. The mock
server aligned with that expectation. As a result the error message
has another content.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
Diffstat (limited to 'internal/testhelper')
-rw-r--r-- | internal/testhelper/testserver.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go index d8a2f6d47..486708749 100644 --- a/internal/testhelper/testserver.go +++ b/internal/testhelper/testserver.go @@ -789,7 +789,10 @@ func handleCheck(options GitlabTestServerOptions) func(w http.ResponseWriter, r return func(w http.ResponseWriter, r *http.Request) { u, p, ok := r.BasicAuth() if !ok || u != options.User || p != options.Password { - http.Error(w, "authorization failed", http.StatusUnauthorized) + w.WriteHeader(http.StatusUnauthorized) + json.NewEncoder(w).Encode(struct { + Message string `json:"message"` + }{Message: "authorization failed"}) return } |