TestBasicAuth401WithCustomRealm() — gin Function Reference
Architecture documentation for the TestBasicAuth401WithCustomRealm() function in auth_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 216396fe_5115_3e04_e9fa_b17d2f5028a6["TestBasicAuth401WithCustomRealm()"] 8de69f2f_ba6f_8b4b_b264_a61861b36bb6["auth_test.go"] 216396fe_5115_3e04_e9fa_b17d2f5028a6 -->|defined in| 8de69f2f_ba6f_8b4b_b264_a61861b36bb6 style 216396fe_5115_3e04_e9fa_b17d2f5028a6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
auth_test.go lines 121–139
func TestBasicAuth401WithCustomRealm(t *testing.T) {
called := false
accounts := Accounts{"foo": "bar"}
router := New()
router.Use(BasicAuthForRealm(accounts, "My Custom \"Realm\""))
router.GET("/login", func(c *Context) {
called = true
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
})
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, "/login", nil)
req.Header.Set("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte("admin:password")))
router.ServeHTTP(w, req)
assert.False(t, called)
assert.Equal(t, http.StatusUnauthorized, w.Code)
assert.Equal(t, "Basic realm=\"My Custom \\\"Realm\\\"\"", w.Header().Get("WWW-Authenticate"))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestBasicAuth401WithCustomRealm() do?
TestBasicAuth401WithCustomRealm() is a function in the gin codebase, defined in auth_test.go.
Where is TestBasicAuth401WithCustomRealm() defined?
TestBasicAuth401WithCustomRealm() is defined in auth_test.go at line 121.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free