<?php

namespace Tests\Feature;

use App\Models\BannedIp;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class BruteforceBannedIpTest extends TestCase
{
    use RefreshDatabase;

    public function test_active_scope_excludes_expired_bans(): void
    {
        BannedIp::create(['ip' => '1.2.3.4', 'banned_until' => now()->addHour(), 'attempts' => 10]);
        BannedIp::create(['ip' => '5.6.7.8', 'banned_until' => now()->subHour(), 'attempts' => 10]);

        $active = BannedIp::active()->pluck('ip')->all();

        $this->assertSame(['1.2.3.4'], $active);
    }
}
