MCPcopy
hub / github.com/appleboy/gin-jwt / TestMissingAuthenticatorForLoginHandler

Function TestMissingAuthenticatorForLoginHandler

auth_jwt_test.go:236–260  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func 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
262func TestLoginHandler(t *testing.T) {
263 // the middleware to test

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
ginHandlerFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…