@@ -27,47 +27,48 @@ func TestBasicAuth(t *testing.T) {
27
27
auth := Basic + " " + base64 .StdEncoding .EncodeToString ([]byte ("joe:secret" ))
28
28
req .Header .Set (echo .Authorization , auth )
29
29
if ba (c ) != nil {
30
- t .Error ("basic auth should pass" )
30
+ t .Error ("expected ` pass` " )
31
31
}
32
32
33
33
// Case insensitive
34
34
auth = "basic " + base64 .StdEncoding .EncodeToString ([]byte ("joe:secret" ))
35
35
req .Header .Set (echo .Authorization , auth )
36
36
if ba (c ) != nil {
37
- t .Error ("basic auth should ignore case and pass " )
37
+ t .Error ("expected `pass` with case insensitive header " )
38
38
}
39
39
40
40
//---------------------
41
41
// Invalid credentials
42
42
//---------------------
43
43
44
- auth = Basic + " " + base64 .StdEncoding .EncodeToString ([]byte (" joe: secret" ))
44
+ // Incorrect password
45
+ auth = Basic + " " + base64 .StdEncoding .EncodeToString ([]byte ("joe: password" ))
45
46
req .Header .Set (echo .Authorization , auth )
46
47
ba = BasicAuth (fn )
47
48
if ba (c ) == nil {
48
- t .Error ("basic auth should fail " )
49
+ t .Error ("expected `fail` with incorrect password " )
49
50
}
50
51
51
52
// Invalid header
52
53
auth = base64 .StdEncoding .EncodeToString ([]byte (" :secret" ))
53
54
req .Header .Set (echo .Authorization , auth )
54
55
ba = BasicAuth (fn )
55
56
if ba (c ) == nil {
56
- t .Error ("basic auth should fail for invalid scheme " )
57
+ t .Error ("expected ` fail` with invalid auth header " )
57
58
}
58
59
59
60
// Invalid scheme
60
61
auth = "Base " + base64 .StdEncoding .EncodeToString ([]byte (" :secret" ))
61
62
req .Header .Set (echo .Authorization , auth )
62
63
ba = BasicAuth (fn )
63
64
if ba (c ) == nil {
64
- t .Error ("basic auth should fail for invalid scheme" )
65
+ t .Error ("expected ` fail` with invalid scheme" )
65
66
}
66
67
67
68
// Empty auth header
68
69
req .Header .Set (echo .Authorization , "" )
69
70
ba = BasicAuth (fn )
70
71
if ba (c ) == nil {
71
- t .Error ("basic auth should fail for empty auth header" )
72
+ t .Error ("expected ` fail` with empty auth header" )
72
73
}
73
74
}
0 commit comments