From 4e1c06a02a859339d306f1d392be33d3292c3a3e Mon Sep 17 00:00:00 2001 From: Xavier MARCELET Date: Sat, 13 Mar 2021 17:25:04 +0100 Subject: [PATCH] reply with status unauthorized when serving login page --- auth_handler.go | 1 + auth_handler_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/auth_handler.go b/auth_handler.go index 5cc6400..53c2523 100644 --- a/auth_handler.go +++ b/auth_handler.go @@ -134,6 +134,7 @@ func (a AuthHandler) loginPage(w http.ResponseWriter, req *http.Request) { return } if req.Method == http.MethodGet { + w.WriteHeader(http.StatusUnauthorized) w.Write([]byte(makeLoginPageHtml( loginPageTemplate, strings.Title(a.aggrRoute.Name), diff --git a/auth_handler_test.go b/auth_handler_test.go index 5c5ba9b..3d72c69 100644 --- a/auth_handler_test.go +++ b/auth_handler_test.go @@ -118,7 +118,7 @@ var _ = Describe("AuthHandler", func() { authHandler.ServeHTTP(respRecorder, req) - Expect(respRecorder.Code).To(Equal(http.StatusOK)) + Expect(respRecorder.Code).To(Equal(http.StatusUnauthorized)) Expect(respRecorder.Body.String()).To(Equal("Test: /")) }) When("Post username and password from login page", func() {