我生成了两个令牌:
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 的价值