Home / Function/ Test_BasicAuth_HeaderLimit() — fiber Function Reference

Test_BasicAuth_HeaderLimit() — fiber Function Reference

Architecture documentation for the Test_BasicAuth_HeaderLimit() function in basicauth_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  8b31c223_e24c_4823_0b21_c68d4b161c33["Test_BasicAuth_HeaderLimit()"]
  c1fa52c0_acd4_56de_8c46_542417f3c9b8["basicauth_test.go"]
  8b31c223_e24c_4823_0b21_c68d4b161c33 -->|defined in| c1fa52c0_acd4_56de_8c46_542417f3c9b8
  bfd8a9b6_0e17_60de_7e62_37b7a2f1750e["sha256Hash()"]
  8b31c223_e24c_4823_0b21_c68d4b161c33 -->|calls| bfd8a9b6_0e17_60de_7e62_37b7a2f1750e
  style 8b31c223_e24c_4823_0b21_c68d4b161c33 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/basicauth/basicauth_test.go lines 406–433

func Test_BasicAuth_HeaderLimit(t *testing.T) {
	t.Parallel()
	creds := base64.StdEncoding.EncodeToString([]byte("john:doe"))
	hashedJohn := sha256Hash("doe")

	t.Run("too large", func(t *testing.T) {
		t.Parallel()
		app := fiber.New()
		app.Use(New(Config{Users: map[string]string{"john": hashedJohn}, HeaderLimit: 10}))
		req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
		req.Header.Set(fiber.HeaderAuthorization, "Basic "+creds)
		resp, err := app.Test(req)
		require.NoError(t, err)
		require.Equal(t, fiber.StatusRequestHeaderFieldsTooLarge, resp.StatusCode)
	})

	t.Run("allowed", func(t *testing.T) {
		t.Parallel()
		app := fiber.New()
		app.Use(New(Config{Users: map[string]string{"john": hashedJohn}, HeaderLimit: 100}))
		app.Get("/", func(c fiber.Ctx) error { return c.SendStatus(fiber.StatusTeapot) })
		req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
		req.Header.Set(fiber.HeaderAuthorization, "Basic "+creds)
		resp, err := app.Test(req)
		require.NoError(t, err)
		require.Equal(t, fiber.StatusTeapot, resp.StatusCode)
	})
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does Test_BasicAuth_HeaderLimit() do?
Test_BasicAuth_HeaderLimit() is a function in the fiber codebase, defined in middleware/basicauth/basicauth_test.go.
Where is Test_BasicAuth_HeaderLimit() defined?
Test_BasicAuth_HeaderLimit() is defined in middleware/basicauth/basicauth_test.go at line 406.
What does Test_BasicAuth_HeaderLimit() call?
Test_BasicAuth_HeaderLimit() calls 1 function(s): sha256Hash.

Analyze Your Own Codebase

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

Try Supermodel Free