Home / Function/ Test_BearerErrorFields() — fiber Function Reference

Test_BearerErrorFields() — fiber Function Reference

Architecture documentation for the Test_BearerErrorFields() function in keyauth_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  0fad41e7_9d2a_2e70_f2a0_4c901be1cd7d["Test_BearerErrorFields()"]
  71f55784_a001_0646_0ce7_7ad97067c49c["keyauth_test.go"]
  0fad41e7_9d2a_2e70_f2a0_4c901be1cd7d -->|defined in| 71f55784_a001_0646_0ce7_7ad97067c49c
  style 0fad41e7_9d2a_2e70_f2a0_4c901be1cd7d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/keyauth/keyauth_test.go lines 906–924

func Test_BearerErrorFields(t *testing.T) {
	app := fiber.New()
	app.Use(New(Config{
		Validator: func(_ fiber.Ctx, _ string) (bool, error) {
			return false, errors.New("invalid")
		},
		Error:            "invalid_token",
		ErrorDescription: "token expired",
		ErrorURI:         "https://example.com",
	}))
	app.Get("/", func(c fiber.Ctx) error { return c.SendString("OK") })

	req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
	req.Header.Add("Authorization", "Bearer something")
	res, err := app.Test(req)
	require.NoError(t, err)
	require.Equal(t, http.StatusUnauthorized, res.StatusCode)
	require.Equal(t, `Bearer realm="Restricted", error="invalid_token", error_description="token expired", error_uri="https://example.com"`, res.Header.Get("WWW-Authenticate"))
}

Domain

Subdomains

Frequently Asked Questions

What does Test_BearerErrorFields() do?
Test_BearerErrorFields() is a function in the fiber codebase, defined in middleware/keyauth/keyauth_test.go.
Where is Test_BearerErrorFields() defined?
Test_BearerErrorFields() is defined in middleware/keyauth/keyauth_test.go at line 906.

Analyze Your Own Codebase

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

Try Supermodel Free