Home / Function/ Test_BearerErrorURIOnly() — fiber Function Reference

Test_BearerErrorURIOnly() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/keyauth/keyauth_test.go lines 926–943

func Test_BearerErrorURIOnly(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",
		ErrorURI: "https://example.com/docs",
	}))
	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_uri="https://example.com/docs"`, res.Header.Get("WWW-Authenticate"))
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free