Test_CSRF_Chain_Extractor_Empty() — fiber Function Reference
Architecture documentation for the Test_CSRF_Chain_Extractor_Empty() function in csrf_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 57e45f95_3861_0853_7393_8c3b05f392d2["Test_CSRF_Chain_Extractor_Empty()"] 306a0c68_f5a5_b368_f37a_1419425a8fea["csrf_test.go"] 57e45f95_3861_0853_7393_8c3b05f392d2 -->|defined in| 306a0c68_f5a5_b368_f37a_1419425a8fea style 57e45f95_3861_0853_7393_8c3b05f392d2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/csrf/csrf_test.go lines 2152–2182
func Test_CSRF_Chain_Extractor_Empty(t *testing.T) {
t.Parallel()
app := fiber.New()
// Empty chain extractor
emptyChain := extractors.Chain()
app.Use(New(Config{Extractor: emptyChain}))
app.Post("/", func(c fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})
h := app.Handler()
ctx := &fasthttp.RequestCtx{}
// Generate CSRF token
ctx.Request.Header.SetMethod(fiber.MethodGet)
h(ctx)
token := string(ctx.Response.Header.Peek(fiber.HeaderSetCookie))
token = strings.Split(strings.Split(token, ";")[0], "=")[1]
// Test with empty chain - should always fail
ctx.Request.Reset()
ctx.Response.Reset()
ctx.Request.Header.SetMethod(fiber.MethodPost)
ctx.Request.Header.Set("X-Csrf-Token", token)
ctx.Request.Header.SetCookie(ConfigDefault.CookieName, token)
h(ctx)
require.Equal(t, 403, ctx.Response.StatusCode())
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_CSRF_Chain_Extractor_Empty() do?
Test_CSRF_Chain_Extractor_Empty() is a function in the fiber codebase, defined in middleware/csrf/csrf_test.go.
Where is Test_CSRF_Chain_Extractor_Empty() defined?
Test_CSRF_Chain_Extractor_Empty() is defined in middleware/csrf/csrf_test.go at line 2152.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free