Test_BasicAuth_HashVariants_Invalid() — fiber Function Reference
Architecture documentation for the Test_BasicAuth_HashVariants_Invalid() function in basicauth_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD d466c515_0ccf_3526_c73c_d475f5e9d392["Test_BasicAuth_HashVariants_Invalid()"] c1fa52c0_acd4_56de_8c46_542417f3c9b8["basicauth_test.go"] d466c515_0ccf_3526_c73c_d475f5e9d392 -->|defined in| c1fa52c0_acd4_56de_8c46_542417f3c9b8 824a33e0_c7e5_0667_eed0_344e2a530f7a["sha512Hash()"] d466c515_0ccf_3526_c73c_d475f5e9d392 -->|calls| 824a33e0_c7e5_0667_eed0_344e2a530f7a bfd8a9b6_0e17_60de_7e62_37b7a2f1750e["sha256Hash()"] d466c515_0ccf_3526_c73c_d475f5e9d392 -->|calls| bfd8a9b6_0e17_60de_7e62_37b7a2f1750e style d466c515_0ccf_3526_c73c_d475f5e9d392 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/basicauth/basicauth_test.go lines 576–604
func Test_BasicAuth_HashVariants_Invalid(t *testing.T) {
t.Parallel()
pass := "doe"
wrong := "wrong"
bcryptHash, err := bcrypt.GenerateFromPassword([]byte(pass), bcrypt.MinCost)
require.NoError(t, err)
cases := []struct {
name string
hashed string
}{
{"bcrypt", string(bcryptHash)},
{"sha512", sha512Hash(pass)},
{"sha256", sha256Hash(pass)},
{"sha256-hex", func() string { h := sha256.Sum256([]byte(pass)); return hex.EncodeToString(h[:]) }()},
}
for _, tt := range cases {
app := fiber.New()
app.Use(New(Config{Users: map[string]string{"john": tt.hashed}}))
app.Get("/", func(c fiber.Ctx) error { return c.SendStatus(fiber.StatusTeapot) })
creds := base64.StdEncoding.EncodeToString([]byte("john:" + wrong))
req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
req.Header.Set(fiber.HeaderAuthorization, "Basic "+creds)
resp, err := app.Test(req)
require.NoError(t, err)
require.Equal(t, fiber.StatusUnauthorized, resp.StatusCode)
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does Test_BasicAuth_HashVariants_Invalid() do?
Test_BasicAuth_HashVariants_Invalid() is a function in the fiber codebase, defined in middleware/basicauth/basicauth_test.go.
Where is Test_BasicAuth_HashVariants_Invalid() defined?
Test_BasicAuth_HashVariants_Invalid() is defined in middleware/basicauth/basicauth_test.go at line 576.
What does Test_BasicAuth_HashVariants_Invalid() call?
Test_BasicAuth_HashVariants_Invalid() calls 2 function(s): sha256Hash, sha512Hash.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free