create(); $investigation = Investigation::factory()->for($user, 'owner')->create(); $target = $investigation->targets()->create(['type' => 'ip', 'value' => '8.8.8.8', 'created_by' => $user->id]); $source = Source::create(['key' => 'ip-api', 'name' => 'ip-api.com', 'target_types' => ['ip'], 'enabled' => true]); $finding = $target->findings()->create(['source_id' => $source->id, 'status' => 'pending']); $middleware = (new RunFinding($finding->id))->middleware(); $this->assertCount(1, $middleware); $this->assertInstanceOf(RateLimited::class, $middleware[0]); } public function test_failed_marks_the_finding_as_failed(): void { $user = User::factory()->create(); $investigation = Investigation::factory()->for($user, 'owner')->create(); $target = $investigation->targets()->create(['type' => 'ip', 'value' => '8.8.8.8', 'created_by' => $user->id]); $source = Source::create(['key' => 'ip-api', 'name' => 'ip-api.com', 'target_types' => ['ip'], 'enabled' => true]); $finding = $target->findings()->create(['source_id' => $source->id, 'status' => 'pending']); (new RunFinding($finding->id))->failed(new \RuntimeException('retries exhausted')); $finding->refresh(); $this->assertSame('failed', $finding->status); $this->assertStringContainsString('retries exhausted', $finding->error); } }