From ba42bc3377183ef4987b3f718ae3786938f457d6 Mon Sep 17 00:00:00 2001 From: Cory Jacobsen Date: Tue, 22 Oct 2024 15:50:50 -0600 Subject: [PATCH] chore: ensure the package does not add any headers when no config is provided (#103) --- secure_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/secure_test.go b/secure_test.go index 52a5c63..0411d94 100644 --- a/secure_test.go +++ b/secure_test.go @@ -22,6 +22,18 @@ var myHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("bar")) }) +func TestNoConfigOnlyOneHeader(t *testing.T) { + s := New() + + res := httptest.NewRecorder() + req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://example.com/foo", nil) + + s.Handler(myHandler).ServeHTTP(res, req) + + expect(t, len(res.Header()), 1) + expect(t, strings.Contains(res.Header().Get("Content-Type"), "text/plain"), true) +} + func TestNoConfig(t *testing.T) { s := New()