A free open source IT asset/license management system
Added import gate to importer boot method
snipe1ed650e8b1ec
diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.phpindex 6ef5a028a7..391f47a7d1 100644--- a/app/Livewire/Importer.php+++ b/app/Livewire/Importer.php@@ -358,6 +358,11 @@ class Importer extends Component}}+ public function boot(): void+ {+ $this->authorize('import');+ }+public function mount(){$this->authorize('import');diff --git a/tests/Feature/Livewire/ImporterLockedPropertyTest.php b/tests/Feature/Livewire/ImporterLockedPropertyTest.phpindex 3f30a535a4..1b298b7b64 100644--- a/tests/Feature/Livewire/ImporterLockedPropertyTest.php+++ b/tests/Feature/Livewire/ImporterLockedPropertyTest.php@@ -5,6 +5,7 @@ namespace Tests\Feature\Livewire;use App\Livewire\Importer;use App\Models\Asset;use App\Models\User;+use Illuminate\Support\Facades\Auth;use Livewire\Features\SupportLockedProperties\CannotUpdateLockedPropertyException;use Livewire\Livewire;use Tests\TestCase;@@ -97,6 +98,32 @@ class ImporterLockedPropertyTest extends TestCase);}+ public function test_boot_rejects_action_calls_from_a_caller_without_import_permission(): void+ {+ $authorized = User::factory()->canImport()->create();+ $unauthorized = User::factory()->create();++ $component = Livewire::actingAs($authorized)->test(Importer::class);++ // Simulate the "permission revoked mid-session" case: swap auth+ // to a caller without `import` and attempt an action. boot()+ // runs before the action and Livewire converts the resulting+ // AuthorizationException to a 403 status on the component.+ Auth::login($unauthorized);++ $component->call('nextStep')->assertStatus(403);+ }++ public function test_mount_still_rejects_unauthorized_callers(): void+ {+ // Baseline: boot() firing in the same request means an initial+ // mount by an unauthorized caller still fails. Guards against a+ // future refactor that accidentally weakens boot without noticing.+ Livewire::actingAs(User::factory()->create())+ ->test(Importer::class)+ ->assertStatus(403);+ }+public function test_every_class_in_the_map_implements_importable(): void{// Every class pointer in $required_field_model_map