This commit is contained in:
hashbro
2026-08-12 02:51:39 +08:00
parent 4983077085
commit f285d35d86
3 changed files with 34 additions and 0 deletions
+18
View File
@@ -42,6 +42,24 @@ class PageVisitTest extends TestCase
$this->assertSame($ua, $row->user_agent);
}
#[Test]
public function hit_uses_x_forwarded_for_when_proxies_trusted(): void
{
Cache::flush();
$this->call('GET', '/statistic/t', [
'c' => self::CHANNEL,
'u' => '11111111-2222-4333-8444-555555555555',
], [], [], [
'REMOTE_ADDR' => '104.16.1.1',
'HTTP_X_FORWARDED_FOR' => '203.0.113.50',
])->assertOk();
$row = PageVisit::query()->first();
$this->assertNotNull($row);
$this->assertSame('203.0.113.50', $row->ip);
}
#[Test]
public function hit_debounces_duplicate_uid(): void
{