Home / Function/ Test_BasicAuth_AuthorizerCtx() — fiber Function Reference

Test_BasicAuth_AuthorizerCtx() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/basicauth/basicauth_test.go lines 112–136

func Test_BasicAuth_AuthorizerCtx(t *testing.T) {
	t.Parallel()
	app := fiber.New()

	called := false
	app.Use(New(Config{
		Authorizer: func(user, pass string, c fiber.Ctx) bool {
			called = true
			require.Equal(t, "john", user)
			require.Equal(t, "doe", pass)
			require.Equal(t, "/ctx", c.Path())
			return true
		},
	}))

	app.Get("/ctx", func(c fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) })

	creds := base64.StdEncoding.EncodeToString([]byte("john:doe"))
	req := httptest.NewRequest(fiber.MethodGet, "/ctx", http.NoBody)
	req.Header.Set(fiber.HeaderAuthorization, "Basic "+creds)
	resp, err := app.Test(req)
	require.NoError(t, err)
	require.Equal(t, fiber.StatusOK, resp.StatusCode)
	require.True(t, called)
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free