Summer Sale! All accounts are 50% off this week.

hakeemDev's avatar

Testing with Sanctum

Hi, I'm trying to run some tests and when it comes to the sanctum part, it always ends up with 401 code; my tests go with a model that is associated with the user model, for example, there is a user model and post owner model and I want to make tests on post owner model but it always wants an Authenticable and not a model, I even use hasApiToken trait but no luck, so is there any way to make it work with non-user model?

Thanks,

0 likes
2 replies
tisuchi's avatar

@hakeemdev Did you try with actingAs() to make your request authenticable?

BTW, 401 means that somehow you are not authorized to perform this request.

Please or to participate in this conversation.