You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test('api token can be used to access authenticated routes', async ({ client }) => {
const unauthorizedRequest = await client.get('/api/users')
unauthorizedRequest.assertStatus(401)
const admin = await User.findByOrFail("username", "admin");
// Delete all tokens to actually test this.
await Database.rawQuery(`DELETE FROM api_tokens WHERE user_id = ${admin.id}`)
const authorizedRequest = await client.get('/api/users').guard('api').loginAs(admin)
authorizedRequest.assertStatus(200)
})
Issue
Maybe I am doing this wrong but I am trying to write a test to verify that api token authentication is working properly. My first issue is that I get the following type error with the above code:
My second issue is that is seems that even if I delete all of the api tokens before attempted to make the request I am still receiving a success response. I would expect that this would fail. Am I not doing this right?
The text was updated successfully, but these errors were encountered:
@RomainLanz Thanks for the quick reply and I apologize for not doing a thorough search before posting this. I am assuming that I can simply upgrade the auth package to the latest version to resolve this issue? Giving that a shot now.
Package version
@adonisjs/auth 8.2.1
Node.js and npm version
v16.13.1 and 8.1.2
Sample Code (to reproduce the issue)
Issue
Maybe I am doing this wrong but I am trying to write a test to verify that api token authentication is working properly. My first issue is that I get the following type error with the above code:
My second issue is that is seems that even if I delete all of the api tokens before attempted to make the request I am still receiving a success response. I would expect that this would fail. Am I not doing this right?
The text was updated successfully, but these errors were encountered: