Home / Function/ Test_BasicAuth_ControlChars() — fiber Function Reference

Test_BasicAuth_ControlChars() — fiber Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  378e49f0_2ee1_2b45_988c_36a34f16d45b["Test_BasicAuth_ControlChars()"]
  c1fa52c0_acd4_56de_8c46_542417f3c9b8["basicauth_test.go"]
  378e49f0_2ee1_2b45_988c_36a34f16d45b -->|defined in| c1fa52c0_acd4_56de_8c46_542417f3c9b8
  style 378e49f0_2ee1_2b45_988c_36a34f16d45b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/basicauth/basicauth_test.go lines 263–291

func Test_BasicAuth_ControlChars(t *testing.T) {
	t.Parallel()
	called := false
	app := fiber.New()
	app.Use(New(Config{
		Authorizer: func(_, _ string, _ fiber.Ctx) bool {
			called = true
			return true
		},
	}))

	creds := []string{
		base64.StdEncoding.EncodeToString([]byte("john:\x01doe")),
		base64.StdEncoding.EncodeToString([]byte("jo\x7Fhn:doe")),
		base64.StdEncoding.EncodeToString([]byte{'j', 'o', 'h', 'n', ':', 0x85, 'd', 'o', 'e'}),
		base64.StdEncoding.EncodeToString([]byte{'j', 'o', 'h', 'n', ':', 0x9F, 'd', 'o', 'e'}),
	}

	for _, c := range creds {
		called = false
		req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
		req.Header.Set(fiber.HeaderAuthorization, "Basic "+c)
		resp, err := app.Test(req)
		require.NoError(t, err)
		require.Equal(t, fiber.StatusBadRequest, resp.StatusCode)
		require.Empty(t, resp.Header.Get(fiber.HeaderWWWAuthenticate))
		require.False(t, called)
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Test_BasicAuth_ControlChars() do?
Test_BasicAuth_ControlChars() is a function in the fiber codebase, defined in middleware/basicauth/basicauth_test.go.
Where is Test_BasicAuth_ControlChars() defined?
Test_BasicAuth_ControlChars() is defined in middleware/basicauth/basicauth_test.go at line 263.

Analyze Your Own Codebase

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

Try Supermodel Free