Home / File/ csrf_test.go — fiber Source File

csrf_test.go — fiber Source File

Architecture documentation for csrf_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberMiddleware Security 1 imports 46 functions 3 classes

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)

Subdomains

Dependencies

  • context

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