mirror of
https://github.com/labstack/echo.git
synced 2024-12-26 20:54:00 +02:00
Invalid auth test case
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
0da05cb7f2
commit
e55f5f1636
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user