Skip to content

Commit ba42bc3

Browse files
authored
chore: ensure the package does not add any headers when no config is provided (#103)
1 parent c88f919 commit ba42bc3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

secure_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ var myHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
2222
_, _ = w.Write([]byte("bar"))
2323
})
2424

25+
func TestNoConfigOnlyOneHeader(t *testing.T) {
26+
s := New()
27+
28+
res := httptest.NewRecorder()
29+
req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://example.com/foo", nil)
30+
31+
s.Handler(myHandler).ServeHTTP(res, req)
32+
33+
expect(t, len(res.Header()), 1)
34+
expect(t, strings.Contains(res.Header().Get("Content-Type"), "text/plain"), true)
35+
}
36+
2537
func TestNoConfig(t *testing.T) {
2638
s := New()
2739

0 commit comments

Comments
 (0)