Home / Function/ Test_EarlyData() — fiber Function Reference

Test_EarlyData() — fiber Function Reference

Architecture documentation for the Test_EarlyData() function in earlydata_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  22cab21c_8426_7b52_02c4_68f2b7486d46["Test_EarlyData()"]
  89ff38ec_40bf_204e_af8c_37d168e2a1f9["earlydata_test.go"]
  22cab21c_8426_7b52_02c4_68f2b7486d46 -->|defined in| 89ff38ec_40bf_204e_af8c_37d168e2a1f9
  1b236aeb_bf33_2e17_b819_48c58c201c5e["appWithConfig()"]
  22cab21c_8426_7b52_02c4_68f2b7486d46 -->|calls| 1b236aeb_bf33_2e17_b819_48c58c201c5e
  d055c651_518b_e138_97aa_b59d12e0a63f["executeExpectations()"]
  22cab21c_8426_7b52_02c4_68f2b7486d46 -->|calls| d055c651_518b_e138_97aa_b59d12e0a63f
  style 22cab21c_8426_7b52_02c4_68f2b7486d46 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/earlydata/earlydata_test.go lines 112–163

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

	untrustedExpectations := []requestExpectation{
		{method: fiber.MethodGet, status: fiber.StatusOK},
		{method: fiber.MethodGet, header: headerValOff, status: fiber.StatusOK},
		{method: fiber.MethodGet, header: headerValOn, status: fiber.StatusTooEarly},
		{method: fiber.MethodPost, status: fiber.StatusOK},
		{method: fiber.MethodPost, header: headerValOff, status: fiber.StatusOK},
		{method: fiber.MethodPost, header: headerValOn, status: fiber.StatusTooEarly},
	}

	trustedExpectations := []requestExpectation{
		{method: fiber.MethodGet, status: fiber.StatusOK},
		{method: fiber.MethodGet, header: headerValOff, status: fiber.StatusOK},
		{method: fiber.MethodGet, header: headerValOn, status: fiber.StatusOK},
		{method: fiber.MethodPost, status: fiber.StatusOK},
		{method: fiber.MethodPost, header: headerValOff, status: fiber.StatusOK},
		{method: fiber.MethodPost, header: headerValOn, status: fiber.StatusTooEarly},
	}

	t.Run("empty config", func(t *testing.T) {
		t.Parallel()
		app := appWithConfig(t, nil)
		executeExpectations(t, app, untrustedRemoteAddr, untrustedExpectations)
	})
	t.Run("default config", func(t *testing.T) {
		t.Parallel()
		app := appWithConfig(t, &fiber.Config{})
		executeExpectations(t, app, untrustedRemoteAddr, untrustedExpectations)
	})

	t.Run("config with TrustProxy and untrusted remote", func(t *testing.T) {
		t.Parallel()
		app := appWithConfig(t, &fiber.Config{
			TrustProxy: true,
		})
		executeExpectations(t, app, untrustedRemoteAddr, untrustedExpectations)
	})
	t.Run("config with TrustProxy and trusted TrustProxyConfig.Proxies", func(t *testing.T) {
		t.Parallel()
		app := appWithConfig(t, &fiber.Config{
			TrustProxy: true,
			TrustProxyConfig: fiber.TrustProxyConfig{
				Proxies: []string{
					"0.0.0.0",
				},
			},
		})
		executeExpectations(t, app, trustedRemoteAddr, trustedExpectations)
	})
}

Domain

Subdomains

Frequently Asked Questions

What does Test_EarlyData() do?
Test_EarlyData() is a function in the fiber codebase, defined in middleware/earlydata/earlydata_test.go.
Where is Test_EarlyData() defined?
Test_EarlyData() is defined in middleware/earlydata/earlydata_test.go at line 112.
What does Test_EarlyData() call?
Test_EarlyData() calls 2 function(s): appWithConfig, executeExpectations.

Analyze Your Own Codebase

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

Try Supermodel Free