debianProfile(); $detector = Mockery::mock(OsDetector::class); $detector->shouldReceive('detect')->andReturn($os); $captured = ''; $fleet = Mockery::mock(FleetService::class); $fleet->shouldReceive('runPrivileged') ->andReturnUsing(function ($server, $cmd) use (&$captured) { $captured = $cmd; // fail2ban running from a source/`rc` install: present + active. return ['ok' => true, 'output' => "fail2ban 1 active\nfirewall 1 active\nautoupdate 0 inactive"]; }); $service = new HardeningService($fleet, Mockery::mock(FirewallService::class), $detector); $rows = $service->state(new Server); // fail2ban installed-probe gains the binary fallback (was dpkg ^ii only — the bug). $this->assertStringContainsString('command -v fail2ban-client', $captured); // firewall installed-probe gains the package-manager fallback (was command -v only). $this->assertStringContainsString('dpkg -l ufw', $captured); $f2b = collect($rows)->firstWhere('key', 'fail2ban'); $this->assertTrue($f2b['featureOn'], 'fail2ban active must read as on'); } }