]> BookStack Code Mirror - bookstack/blobdiff - tests/Actions/AuditLogTest.php
Updated minimum php version from 7.3 to 7.4
[bookstack] / tests / Actions / AuditLogTest.php
index 3bdfc3d1a18dc40d6ea33b7ab916021afae6e67e..8266fd972f1abc540c40baa45a7d4336b56c8c78 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Tests\Actions;
 
+use function app;
 use BookStack\Actions\Activity;
 use BookStack\Actions\ActivityLogger;
 use BookStack\Actions\ActivityType;
@@ -11,9 +12,8 @@ use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Tools\TrashCan;
 use Carbon\Carbon;
-use Tests\TestCase;
-use function app;
 use function config;
+use Tests\TestCase;
 
 class AuditLogTest extends TestCase
 {
@@ -169,6 +169,32 @@ class AuditLogTest extends TestCase
         $resp->assertSee('192.123.45.1');
     }
 
+    public function test_ip_address_is_searchable()
+    {
+        config()->set('app.proxies', '*');
+        $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->actingAs($editor)->put($page->getUrl(), [
+            'name' => 'Updated page',
+            'html' => '<p>Updated content</p>',
+        ], [
+            'X-Forwarded-For' => '192.122.45.1',
+        ])->assertRedirect($page->refresh()->getUrl());
+
+        $resp = $this->asAdmin()->get('/settings/audit?&ip=192.123');
+        $resp->assertSee('192.123.45.1');
+        $resp->assertDontSee('192.122.45.1');
+    }
+
     public function test_ip_address_not_logged_in_demo_mode()
     {
         config()->set('app.proxies', '*');