1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Added ability to adjust stored IP address precision

Included tests to cover.

For #3560
This commit is contained in:
Dan Brown
2022-07-23 13:41:29 +01:00
parent 67d12cc1df
commit 4e8995c3d0
7 changed files with 150 additions and 3 deletions

View File

@@ -218,4 +218,27 @@ class AuditLogTest extends TestCase
'entity_id' => $page->id,
]);
}
public function test_ip_address_respects_precision_setting()
{
config()->set('app.proxies', '*');
config()->set('app.ip_address_precision', 2);
$editor = $this->getEditor();
/** @var Page $page */
$page = Page::query()->first();
$this->actingAs($editor)->put($page->getUrl(), [
'name' => 'Updated page',
'html' => '<p>Updated content</p>',
], [
'X-Forwarded-For' => '192.123.45.1',
])->assertRedirect($page->refresh()->getUrl());
$this->assertDatabaseHas('activities', [
'type' => ActivityType::PAGE_UPDATE,
'ip' => '192.123.x.x',
'user_id' => $editor->id,
'entity_id' => $page->id,
]);
}
}