测试API Jetstream Sanctum Laravel 8x的标题存在问题,并获得许可
我生成了两个令牌:测试API Jetstream Sanctum Laravel 8x的标题存在问题,并获得许可,laravel,api,header,laravel-sanctum,Laravel,Api,Header,Laravel Sanctum,我生成了两个令牌: tokenA = As2 ... xxxxx //can perform ONLY create tokenB = Bs2 ... xxxxx //can perform ONLY update 我有以下问题 $response = $this->withHeaders([ 'Accept' => 'application/json', 'Authorization' => 'Bearer '.$token
tokenA = As2 ... xxxxx //can perform ONLY create
tokenB = Bs2 ... xxxxx //can perform ONLY update
我有以下问题
$response = $this->withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$tokenA],
])->post('/api/store',$data);
$response->assertStatus(201);
//the store is made without problems
$response = $this->withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer '.tokenB,
])->put('/api/update',$dataUpdate);
$respone->assertStatus(200);
//the test fails and returns 403. As if you don't have permission to do that
如果我只打电话
$response = $this->withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer '.tokenB,
])->put('/api/update',$dataUpdate);
$response->assertStatus(200);
执行更新时没有问题
如何依次运行存储和更新
$response似乎继续持有tokenA的值