Home / Function/ Test_BearerInsufficientScope() — fiber Function Reference

Test_BearerInsufficientScope() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/keyauth/keyauth_test.go lines 945–962

func Test_BearerInsufficientScope(t *testing.T) {
	app := fiber.New()
	app.Use(New(Config{
		Validator: func(_ fiber.Ctx, _ string) (bool, error) {
			return false, errors.New("invalid")
		},
		Error: ErrorInsufficientScope,
		Scope: "read",
	}))
	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="insufficient_scope", scope="read"`, res.Header.Get("WWW-Authenticate"))
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free