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

Function Test_CORS_AllowOrigins_NormalizedExactLookup

middleware/cors/cors_test.go:104–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func Test_CORS_AllowOrigins_NormalizedExactLookup(t *testing.T) {
105 t.Parallel()
106
107 app := fiber.New()
108 app.Use(New(Config{AllowOrigins: []string{" HTTP://EXAMPLE.COM/ "}}))
109
110 origin := "http://example.com"
111
112 ctx := &fasthttp.RequestCtx{}
113 ctx.Request.Header.SetMethod(fiber.MethodOptions)
114 ctx.Request.Header.Set(fiber.HeaderAccessControlRequestMethod, fiber.MethodGet)
115 ctx.Request.Header.Set(fiber.HeaderOrigin, origin)
116 app.Handler()(ctx)
117
118 require.Equal(t, origin, string(ctx.Response.Header.Peek(fiber.HeaderAccessControlAllowOrigin)))
119}
120
121func testDefaultOrEmptyConfig(t *testing.T, app *fiber.App) {
122 t.Helper()

Callers

nothing calls this directly

Calls 6

SetMethodMethod · 0.80
HandlerMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
UseMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected