csrf_test.go — fiber Source File
Architecture documentation for csrf_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 306a0c68_f5a5_b368_f37a_1419425a8fea["csrf_test.go"] cc7104af_aece_1fe5_3985_791c7f34910c["context"] 306a0c68_f5a5_b368_f37a_1419425a8fea --> cc7104af_aece_1fe5_3985_791c7f34910c style 306a0c68_f5a5_b368_f37a_1419425a8fea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package csrf
import (
"context"
"errors"
"net"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/extractors"
"github.com/gofiber/fiber/v3/middleware/session"
"github.com/gofiber/utils/v2"
"github.com/stretchr/testify/require"
"github.com/valyala/fasthttp"
)
type failingCSRFStorage struct {
data map[string][]byte
errs map[string]error
}
func newFailingCSRFStorage() *failingCSRFStorage {
return &failingCSRFStorage{
data: make(map[string][]byte),
errs: make(map[string]error),
}
}
func (s *failingCSRFStorage) GetWithContext(_ context.Context, key string) ([]byte, error) {
if err, ok := s.errs["get|"+key]; ok && err != nil {
return nil, err
}
if val, ok := s.data[key]; ok {
return append([]byte(nil), val...), nil
}
return nil, nil
}
var trustedProxyConfig = fiber.Config{
TrustProxy: true,
TrustProxyConfig: fiber.TrustProxyConfig{
Proxies: []string{"0.0.0.0"},
},
}
func newTrustedApp() *fiber.App {
return fiber.New(trustedProxyConfig)
}
func newTrustedRequestCtx() *fasthttp.RequestCtx {
ctx := &fasthttp.RequestCtx{}
ctx.SetRemoteAddr(net.Addr(&net.TCPAddr{IP: net.ParseIP("0.0.0.0")}))
return ctx
}
// ... (2418 more lines)
Domain
Subdomains
Functions
- Benchmark_Middleware_CSRF_Check()
- Benchmark_Middleware_CSRF_GenerateToken()
- TestCSRFStorageDeleteError()
- TestCSRFStorageGetError()
- TestCSRFStorageSetError()
- Test_CSRF()
- Test_CSRF_All_Extractors()
- Test_CSRF_Chain_Extractor()
- Test_CSRF_Chain_Extractor_Empty()
- Test_CSRF_Chain_Extractor_SingleExtractor()
- Test_CSRF_Cookie_Injection_Exploit()
- Test_CSRF_DeleteToken()
- Test_CSRF_DeleteToken_WithSession()
- Test_CSRF_ErrorHandler_EmptyToken()
- Test_CSRF_ErrorHandler_InvalidToken()
- Test_CSRF_ErrorHandler_MissingReferer()
- Test_CSRF_ExpiredToken()
- Test_CSRF_ExpiredToken_WithSession()
- Test_CSRF_Extractor_EmptyString()
- Test_CSRF_Extractors_ErrorTypes()
- Test_CSRF_FromContextMethods()
- Test_CSRF_FromContextMethods_Invalid()
- Test_CSRF_From_Custom()
- Test_CSRF_From_Form()
- Test_CSRF_From_Param()
- Test_CSRF_From_Query()
- Test_CSRF_InvalidURLHeaders()
- Test_CSRF_MultiUseToken()
- Test_CSRF_Next()
- Test_CSRF_Origin()
- Test_CSRF_Param_Extractor()
- Test_CSRF_Param_Extractor_Missing()
- Test_CSRF_Referer()
- Test_CSRF_SecFetchSite()
- Test_CSRF_SingleUseToken()
- Test_CSRF_TokenFromContext()
- Test_CSRF_TrustedOrigins()
- Test_CSRF_TrustedOrigins_InvalidOrigins()
- Test_CSRF_UnsafeHeaderValue()
- Test_CSRF_WithSession()
- Test_CSRF_WithSession_Middleware()
- Test_deleteTokenFromStorage()
- Test_storageManager_logKey()
- newFailingCSRFStorage()
- newTrustedApp()
- newTrustedRequestCtx()
Classes
Dependencies
- context
Source
Frequently Asked Questions
What does csrf_test.go do?
csrf_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberMiddleware domain, Security subdomain.
What functions are defined in csrf_test.go?
csrf_test.go defines 46 function(s): Benchmark_Middleware_CSRF_Check, Benchmark_Middleware_CSRF_GenerateToken, TestCSRFStorageDeleteError, TestCSRFStorageGetError, TestCSRFStorageSetError, Test_CSRF, Test_CSRF_All_Extractors, Test_CSRF_Chain_Extractor, Test_CSRF_Chain_Extractor_Empty, Test_CSRF_Chain_Extractor_SingleExtractor, and 36 more.
What does csrf_test.go depend on?
csrf_test.go imports 1 module(s): context.
Where is csrf_test.go in the architecture?
csrf_test.go is located at middleware/csrf/csrf_test.go (domain: FiberMiddleware, subdomain: Security, directory: middleware/csrf).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free