Skip to content
Snippets Groups Projects
Commit f5242f20 authored by Will McCutchen's avatar Will McCutchen
Browse files

Fix basic auth handler

parent 877cf2d6
Branches
Tags
No related merge requests found
......@@ -301,6 +301,7 @@ func (h *HTTPBin) BasicAuth(w http.ResponseWriter, r *http.Request) {
authorized := givenUser == expectedUser && givenPass == expectedPass
if !authorized {
status = http.StatusUnauthorized
w.Header().Set("WWW-Authenticate", `Basic realm="Fake Realm"`)
}
body, _ := json.Marshal(&authResponse{
......
......@@ -938,6 +938,7 @@ func TestBasicAuth(t *testing.T) {
assertStatusCode(t, w, http.StatusUnauthorized)
assertContentType(t, w, jsonContentType)
assertHeader(t, w, "WWW-Authenticate", `Basic realm="Fake Realm"`)
resp := &authResponse{}
json.Unmarshal(w.Body.Bytes(), resp)
......@@ -959,6 +960,7 @@ func TestBasicAuth(t *testing.T) {
assertStatusCode(t, w, http.StatusUnauthorized)
assertContentType(t, w, jsonContentType)
assertHeader(t, w, "WWW-Authenticate", `Basic realm="Fake Realm"`)
resp := &authResponse{}
json.Unmarshal(w.Body.Bytes(), resp)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment