Route not authenticated but still my test fails


#1

When I have this:

Route.group(() => {                                                                                                                              
  Route.resource('users', 'UserController')                                                                                                
    .apiOnly()                                                                                                                                   
}).prefix(apiVersion)                                                                                                                            

My test goes well:

test('No auth here', async( { client } ) => {                                                                                                    
  const response = await client.get(`${apiVersion}/users`).end()                                                                              
  response.assertStatus(200)                                                                                                                     
})

But I want to authenticate some routes only, the test fails (I get 500 instead of 200):

Route.group(() => {                                                                                                                              
  Route.resource('users', 'UserController')                                                                                                
    .apiOnly()                                                                                                                                   
}).prefix(apiVersion)                                                                                                                            
  .middleware(new Map([                                                                                                                            
    [['store', 'update', 'destroy'], ['auth']]  
 ]))

Why my test fails?


#2

500 status code means there is an Internal error and not an authentication error. What make you come a conclusion that authentication is making the test fail?

Also simply log response.error to see what the error is