3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 11:15:42 +00:00
Files
snipe-it/tests/Feature/Livewire/LdapSettingsAuthorizationTest.php
2026-07-31 15:58:02 +01:00

36 lines
1011 B
PHP

<?php
namespace Tests\Feature\Livewire;
use App\Livewire\LdapSettings;
use App\Models\User;
use Livewire\Livewire;
use Tests\TestCase;
/**
* Regression coverage for the Livewire snapshot-replay authorization bypass
* reported by PizzaStev3 (2026-07-31). LdapSettings had an abort_unless
* check in mount() which only fires on the initial page render. Snapshot
* replay to /livewire/update went through hydrate() -> action methods
* without re-entering mount(). Now duplicated into boot() which fires on
* every Livewire request.
*/
class LdapSettingsAuthorizationTest extends TestCase
{
public function test_superadmin_can_mount()
{
$this->actingAs(User::factory()->firstAdmin()->create());
Livewire::test(LdapSettings::class)
->assertStatus(200);
}
public function test_non_superadmin_cannot_mount_or_replay()
{
$this->actingAs(User::factory()->create());
Livewire::test(LdapSettings::class)
->assertStatus(403);
}
}