@@ -93,15 +93,15 @@ func TestBasicAuthSucceed(t *testing.T) {
93
93
router := New ()
94
94
router .Use (BasicAuth (accounts ))
95
95
router .GET ("/login" , func (c * Context ) {
96
- c .String (200 , c .MustGet (AuthUserKey ).(string ))
96
+ c .String (http . StatusOK , c .MustGet (AuthUserKey ).(string ))
97
97
})
98
98
99
99
w := httptest .NewRecorder ()
100
100
req , _ := http .NewRequest ("GET" , "/login" , nil )
101
101
req .Header .Set ("Authorization" , authorizationHeader ("admin" , "password" ))
102
102
router .ServeHTTP (w , req )
103
103
104
- assert .Equal (t , 200 , w .Code )
104
+ assert .Equal (t , http . StatusOK , w .Code )
105
105
assert .Equal (t , "admin" , w .Body .String ())
106
106
}
107
107
@@ -112,7 +112,7 @@ func TestBasicAuth401(t *testing.T) {
112
112
router .Use (BasicAuth (accounts ))
113
113
router .GET ("/login" , func (c * Context ) {
114
114
called = true
115
- c .String (200 , c .MustGet (AuthUserKey ).(string ))
115
+ c .String (http . StatusOK , c .MustGet (AuthUserKey ).(string ))
116
116
})
117
117
118
118
w := httptest .NewRecorder ()
@@ -121,7 +121,7 @@ func TestBasicAuth401(t *testing.T) {
121
121
router .ServeHTTP (w , req )
122
122
123
123
assert .False (t , called )
124
- assert .Equal (t , 401 , w .Code )
124
+ assert .Equal (t , http . StatusUnauthorized , w .Code )
125
125
assert .Equal (t , "Basic realm=\" Authorization Required\" " , w .HeaderMap .Get ("WWW-Authenticate" ))
126
126
}
127
127
@@ -132,7 +132,7 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
132
132
router .Use (BasicAuthForRealm (accounts , "My Custom \" Realm\" " ))
133
133
router .GET ("/login" , func (c * Context ) {
134
134
called = true
135
- c .String (200 , c .MustGet (AuthUserKey ).(string ))
135
+ c .String (http . StatusOK , c .MustGet (AuthUserKey ).(string ))
136
136
})
137
137
138
138
w := httptest .NewRecorder ()
@@ -141,6 +141,6 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
141
141
router .ServeHTTP (w , req )
142
142
143
143
assert .False (t , called )
144
- assert .Equal (t , 401 , w .Code )
144
+ assert .Equal (t , http . StatusUnauthorized , w .Code )
145
145
assert .Equal (t , "Basic realm=\" My Custom \\ \" Realm\\ \" \" " , w .HeaderMap .Get ("WWW-Authenticate" ))
146
146
}
0 commit comments