create(); $attacker = Customer::factory()->create(); $vm = ModuleVmware::create([ 'name' => 'owner-vm', 'customer_id' => $owner->id, 'vmware_id' => 'vm-1001', 'status' => 1, ]); $response = $this->actingAs($attacker, 'client') ->withHeaders(['x-access-token' => $this->buildClientAccessToken()]) ->getJson('/v1/system/vm-power-state?product=' . $vm->id); // Query đã lọc theo customer_id nên VM của người khác không được tìm thấy (404) // thay vì tìm thấy rồi mới bị chặn bởi check quyền sở hữu phía sau (403) — cả hai đều // an toàn, nhưng 404 xác nhận query đã được scope đúng ngay từ đầu (defense-in-depth). $response->assertStatus(404); } }