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

Function Test_CORS_setSimpleHeaders_NilConfig

middleware/cors/cors_test.go:1709–1720  ·  view source on GitHub ↗

Test_CORS_setSimpleHeaders_NilConfig ensures the nil-config guard returns without panicking or mutating the response headers.

(t *testing.T)

Source from the content-addressed store, hash-verified

1707// Test_CORS_setSimpleHeaders_NilConfig ensures the nil-config guard returns
1708// without panicking or mutating the response headers.
1709func Test_CORS_setSimpleHeaders_NilConfig(t *testing.T) {
1710 t.Parallel()
1711
1712 app := fiber.New()
1713 c := app.AcquireCtx(&fasthttp.RequestCtx{})
1714 defer app.ReleaseCtx(c)
1715
1716 require.NotPanics(t, func() {
1717 setSimpleHeaders(c, "https://example.com", nil)
1718 })
1719 require.Empty(t, string(c.Response().Header.Peek(fiber.HeaderAccessControlAllowOrigin)))
1720}
1721
1722// Test_CORS_setSimpleHeaders_WildcardWithCredentials verifies that when
1723// AllowCredentials is true and the resolved origin is "*", the middleware logs

Callers

nothing calls this directly

Calls 5

setSimpleHeadersFunction · 0.85
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected