MCPcopy
hub / github.com/gofiber/fiber / Test_ContentSecurityPolicy

Function Test_ContentSecurityPolicy

middleware/helmet/helmet_test.go:157–171  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func Test_ContentSecurityPolicy(t *testing.T) {
158 app := fiber.New()
159
160 app.Use(New(Config{
161 ContentSecurityPolicy: "default-src 'none'",
162 }))
163
164 app.Get("/", func(c fiber.Ctx) error {
165 return c.SendString("Hello, World!")
166 })
167
168 resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
169 require.NoError(t, err)
170 require.Equal(t, "default-src 'none'", resp.Header.Get(fiber.HeaderContentSecurityPolicy))
171}
172
173func Test_ContentSecurityPolicyReportOnly(t *testing.T) {
174 app := fiber.New()

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
UseMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65

Tested by

no test coverage detected