1
0
mirror of https://github.com/labstack/echo.git synced 2025-11-27 22:38:25 +02:00

Fixed basic auth to return 401 for error cases

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-04-28 07:09:33 -07:00
parent bca2fd450e
commit a708a6781a
3 changed files with 6 additions and 7 deletions

View File

@@ -40,11 +40,11 @@ func TestBasicAuth(t *testing.T) {
// Empty Authorization header
req.Header().Set(echo.HeaderAuthorization, "")
he = h(c).(*echo.HTTPError)
assert.Equal(t, http.StatusBadRequest, he.Code)
assert.Equal(t, http.StatusUnauthorized, he.Code)
// Invalid Authorization header
auth = base64.StdEncoding.EncodeToString([]byte("invalid"))
req.Header().Set(echo.HeaderAuthorization, auth)
he = h(c).(*echo.HTTPError)
assert.Equal(t, http.StatusBadRequest, he.Code)
assert.Equal(t, http.StatusUnauthorized, he.Code)
}