mirror of
https://github.com/labstack/echo.git
synced 2026-05-16 09:48:24 +02:00
@@ -48,6 +48,14 @@ func TestBasicAuth(t *testing.T) {
|
|||||||
t.Error("basic auth should fail")
|
t.Error("basic auth should fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalid header
|
||||||
|
auth = base64.StdEncoding.EncodeToString([]byte(" :secret"))
|
||||||
|
req.Header.Set(echo.Authorization, auth)
|
||||||
|
b = BasicAuth(fn)
|
||||||
|
if b(c) == nil {
|
||||||
|
t.Error("basic auth should fail for invalid scheme")
|
||||||
|
}
|
||||||
|
|
||||||
// Invalid scheme
|
// Invalid scheme
|
||||||
auth = "Base " + base64.StdEncoding.EncodeToString([]byte(" :secret"))
|
auth = "Base " + base64.StdEncoding.EncodeToString([]byte(" :secret"))
|
||||||
req.Header.Set(echo.Authorization, auth)
|
req.Header.Set(echo.Authorization, auth)
|
||||||
@@ -57,6 +65,7 @@ func TestBasicAuth(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Empty auth header
|
// Empty auth header
|
||||||
|
req.Header.Set(echo.Authorization, "")
|
||||||
b = BasicAuth(fn)
|
b = BasicAuth(fn)
|
||||||
if b(c) == nil {
|
if b(c) == nil {
|
||||||
t.Error("basic auth should fail for empty auth header")
|
t.Error("basic auth should fail for empty auth header")
|
||||||
|
|||||||
Reference in New Issue
Block a user