From 265e523138eb6ee14fc0d58b7f22f916498e7391 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 9 Nov 2018 01:32:09 +0100 Subject: [PATCH] refactor: add realm because it's fun. --- providers/dns/httpreq/httpreq_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/providers/dns/httpreq/httpreq_test.go b/providers/dns/httpreq/httpreq_test.go index cec1d8f3..7b64d297 100644 --- a/providers/dns/httpreq/httpreq_test.go +++ b/providers/dns/httpreq/httpreq_test.go @@ -134,7 +134,8 @@ func TestNewDNSProvider_Present(t *testing.T) { handler: func(rw http.ResponseWriter, req *http.Request) { username, password, ok := req.BasicAuth() if username != "bar" || password != "foo" || !ok { - http.Error(rw, "invalid credentials", http.StatusUnauthorized) + rw.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm="%s"`, "Please enter your username and password.")) + http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) return } @@ -209,7 +210,8 @@ func TestNewDNSProvider_Cleanup(t *testing.T) { handler: func(rw http.ResponseWriter, req *http.Request) { username, password, ok := req.BasicAuth() if username != "bar" || password != "foo" || !ok { - http.Error(rw, "invalid credentials", http.StatusUnauthorized) + rw.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm="%s"`, "Please enter your username and password.")) + http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) return } fmt.Fprint(rw, "lego")