mirror of
https://github.com/gin-gonic/gin.git
synced 2025-08-06 07:40:39 +08:00
Fixes important bug in Basic Auth when using custom realm.
This commit is contained in:
@ -131,7 +131,7 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
|
||||
called := false
|
||||
accounts := Accounts{"foo": "bar"}
|
||||
router := New()
|
||||
router.Use(BasicAuthForRealm(accounts, "My Custom Realm"))
|
||||
router.Use(BasicAuthForRealm(accounts, "My Custom \"Realm\""))
|
||||
router.GET("/login", func(c *Context) {
|
||||
called = true
|
||||
c.String(200, c.MustGet(AuthUserKey).(string))
|
||||
@ -144,5 +144,5 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
|
||||
|
||||
assert.False(t, called)
|
||||
assert.Equal(t, w.Code, 401)
|
||||
assert.Equal(t, w.HeaderMap.Get("WWW-Authenticate"), "Basic realm=\"My Custom Realm\"")
|
||||
assert.Equal(t, w.HeaderMap.Get("WWW-Authenticate"), "Basic realm=\"My Custom \\\"Realm\\\"\"")
|
||||
}
|
||||
|
Reference in New Issue
Block a user