Home / File/ encryptcookie_test.go — fiber Source File

encryptcookie_test.go — fiber Source File

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

File go FiberCore Adapters 1 imports 23 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  ac3bbef3_a1d3_d68b_64fb_619088dde10d["encryptcookie_test.go"]
  86295193_b3d6_5771_ebab_205c899f2f71["rand"]
  ac3bbef3_a1d3_d68b_64fb_619088dde10d --> 86295193_b3d6_5771_ebab_205c899f2f71
  style ac3bbef3_a1d3_d68b_64fb_619088dde10d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package encryptcookie

import (
	"crypto/rand"
	"encoding/base64"
	"errors"
	"net/http"
	"net/http/httptest"
	"strconv"
	"testing"

	"github.com/stretchr/testify/require"
	"github.com/valyala/fasthttp"

	"github.com/gofiber/fiber/v3"
)

func Test_Middleware_Panics(t *testing.T) {
	t.Parallel()

	t.Run("Empty Key", func(t *testing.T) {
		t.Parallel()
		app := fiber.New()
		require.Panics(t, func() {
			app.Use(New(Config{
				Key: "",
			}))
		})
	})

	t.Run("Invalid Key", func(t *testing.T) {
		t.Parallel()
		require.Panics(t, func() {
			GenerateKey(11)
		})
	})
}

func Test_Middleware_InvalidKeys(t *testing.T) {
	t.Parallel()
	tests := []struct {
		length int
	}{
		{length: 11},
		{length: 25},
		{length: 60},
	}

	for _, tt := range tests {
		t.Run(strconv.Itoa(tt.length)+"_length_encrypt", func(t *testing.T) {
			t.Parallel()
			key := make([]byte, tt.length)
			_, err := rand.Read(key)
			require.NoError(t, err)
			keyString := base64.StdEncoding.EncodeToString(key)

			_, err = EncryptCookie("test", "SomeThing", keyString)
			require.Error(t, err)
		})

// ... (788 more lines)

Domain

Subdomains

Classes

Types

Dependencies

  • rand

Frequently Asked Questions

What does encryptcookie_test.go do?
encryptcookie_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Adapters subdomain.
What functions are defined in encryptcookie_test.go?
encryptcookie_test.go defines 23 function(s): Benchmark_Encrypt_Cookie_Custom_Encryptor, Benchmark_Encrypt_Cookie_Custom_Encryptor_Parallel, Benchmark_Encrypt_Cookie_Except, Benchmark_Encrypt_Cookie_Except_Parallel, Benchmark_Encrypt_Cookie_Next, Benchmark_Encrypt_Cookie_Next_Parallel, Benchmark_GenerateKey, Benchmark_GenerateKey_Parallel, Benchmark_Middleware_Encrypt_Cookie, Benchmark_Middleware_Encrypt_Cookie_Parallel, and 13 more.
What does encryptcookie_test.go depend on?
encryptcookie_test.go imports 1 module(s): rand.
Where is encryptcookie_test.go in the architecture?
encryptcookie_test.go is located at middleware/encryptcookie/encryptcookie_test.go (domain: FiberCore, subdomain: Adapters, directory: middleware/encryptcookie).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free