create(); $investigation = Investigation::factory()->for($owner, 'owner')->create(); $target = $investigation->targets()->create(['type' => 'domain', 'value' => 'example.com', 'created_by' => $owner->id]); Source::create(['key' => 'crtsh', 'name' => 'crt.sh', 'target_types' => ['domain'], 'enabled' => true]); Source::create(['key' => 'whois', 'name' => 'WHOIS', 'target_types' => ['domain'], 'enabled' => true]); $this->actingAs($owner) ->post(route('investigations.targets.run-all', [$investigation, $target])) ->assertRedirect(route('investigations.show', $investigation)); Queue::assertPushed(RunFinding::class, 2); $this->assertDatabaseCount('findings', 2); } public function test_run_all_for_investigation_covers_every_target(): void { Queue::fake(); $owner = User::factory()->create(); $investigation = Investigation::factory()->for($owner, 'owner')->create(); $domainTarget = $investigation->targets()->create(['type' => 'domain', 'value' => 'example.com', 'created_by' => $owner->id]); $ipTarget = $investigation->targets()->create(['type' => 'ip', 'value' => '8.8.8.8', 'created_by' => $owner->id]); Source::create(['key' => 'crtsh', 'name' => 'crt.sh', 'target_types' => ['domain'], 'enabled' => true]); Source::create(['key' => 'ip-api', 'name' => 'ip-api.com', 'target_types' => ['ip'], 'enabled' => true]); $this->actingAs($owner) ->post(route('investigations.run-all', $investigation)) ->assertRedirect(route('investigations.show', $investigation)); Queue::assertPushed(RunFinding::class, 2); } public function test_viewer_cannot_bulk_run(): void { $owner = User::factory()->create(); $viewer = User::factory()->create(); $investigation = Investigation::factory()->for($owner, 'owner')->create(); $investigation->users()->attach($viewer, ['role' => 'viewer']); $target = $investigation->targets()->create(['type' => 'domain', 'value' => 'example.com', 'created_by' => $owner->id]); $this->actingAs($viewer) ->post(route('investigations.targets.run-all', [$investigation, $target])) ->assertForbidden(); $this->actingAs($viewer) ->post(route('investigations.run-all', $investigation)) ->assertForbidden(); } }