Home / Function/ Test_Middleware_EncryptionErrorPropagates() — fiber Function Reference

Test_Middleware_EncryptionErrorPropagates() — fiber Function Reference

Architecture documentation for the Test_Middleware_EncryptionErrorPropagates() function in encryptcookie_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  55371846_4158_f3aa_f095_4215d426b978["Test_Middleware_EncryptionErrorPropagates()"]
  ac3bbef3_a1d3_d68b_64fb_619088dde10d["encryptcookie_test.go"]
  55371846_4158_f3aa_f095_4215d426b978 -->|defined in| ac3bbef3_a1d3_d68b_64fb_619088dde10d
  style 55371846_4158_f3aa_f095_4215d426b978 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/encryptcookie/encryptcookie_test.go lines 111–147

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

	testKey := GenerateKey(32)
	expected := errors.New("encrypt failed")

	var captured error
	app := fiber.New(fiber.Config{
		ErrorHandler: func(c fiber.Ctx, err error) error {
			captured = err
			return c.Status(fiber.StatusTeapot).SendString("encryption error")
		},
	})

	app.Use(New(Config{
		Key: testKey,
		Encryptor: func(name, value, _ string) (string, error) {
			if name == "test" {
				return "", expected
			}
			return value, nil
		},
	}))

	app.Get("/", func(c fiber.Ctx) error {
		c.Cookie(&fiber.Cookie{
			Name:  "test",
			Value: "value",
		})
		return nil
	})

	resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
	require.NoError(t, err)
	require.Equal(t, fiber.StatusTeapot, resp.StatusCode)
	require.ErrorIs(t, captured, expected)
}

Domain

Subdomains

Frequently Asked Questions

What does Test_Middleware_EncryptionErrorPropagates() do?
Test_Middleware_EncryptionErrorPropagates() is a function in the fiber codebase, defined in middleware/encryptcookie/encryptcookie_test.go.
Where is Test_Middleware_EncryptionErrorPropagates() defined?
Test_Middleware_EncryptionErrorPropagates() is defined in middleware/encryptcookie/encryptcookie_test.go at line 111.

Analyze Your Own Codebase

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

Try Supermodel Free