(t *testing.T)
| 234 | } |
| 235 | |
| 236 | func TestMissingAuthenticatorForLoginHandler(t *testing.T) { |
| 237 | authMiddleware, err := New(&GinJWTMiddleware{ |
| 238 | Realm: "test zone", |
| 239 | Key: key, |
| 240 | Timeout: time.Hour, |
| 241 | MaxRefresh: time.Hour * 24, |
| 242 | }) |
| 243 | |
| 244 | assert.NoError(t, err) |
| 245 | |
| 246 | handler := ginHandler(authMiddleware) |
| 247 | r := gofight.New() |
| 248 | |
| 249 | r.POST("/login"). |
| 250 | SetJSON(gofight.D{ |
| 251 | "username": testAdmin, |
| 252 | "password": testAdmin, |
| 253 | }). |
| 254 | Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) { |
| 255 | message := gjson.Get(r.Body.String(), "message") |
| 256 | |
| 257 | assert.Equal(t, ErrMissingAuthenticatorFunc.Error(), message.String()) |
| 258 | assert.Equal(t, http.StatusInternalServerError, r.Code) |
| 259 | }) |
| 260 | } |
| 261 | |
| 262 | func TestLoginHandler(t *testing.T) { |
| 263 | // the middleware to test |
nothing calls this directly
no test coverage detected
searching dependent graphs…