Skip to content

Commit

Permalink
chore: ensure the package does not add any headers when no config is …
Browse files Browse the repository at this point in the history
…provided (#103)
  • Loading branch information
unrolled authored Oct 22, 2024
1 parent c88f919 commit ba42bc3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions secure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit ba42bc3

Please sign in to comment.