MCPcopy Create free account
hub / github.com/unrolled/secure / TestCustomXSSProtectionForRequestOnly

Function TestCustomXSSProtectionForRequestOnly

secure_test.go:850–863  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

848}
849
850func TestCustomXSSProtectionForRequestOnly(t *testing.T) {
851 xssVal := "1; report=https://example.com"
852 s := New(Options{
853 CustomBrowserXssValue: xssVal,
854 })
855
856 res := httptest.NewRecorder()
857 req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "/foo", nil)
858
859 s.HandlerForRequestOnly(myHandler).ServeHTTP(res, req)
860
861 expect(t, res.Code, http.StatusOK)
862 expect(t, res.Header().Get("X-XSS-Protection"), "")
863}
864
865func TestBothXSSProtection(t *testing.T) {
866 xssVal := "0"

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
expectFunction · 0.85
HandlerForRequestOnlyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…