Skip to content

Commit 65f7b61

Browse files
committed
Sessions: Ignored extra meta/dist content in history tracking
For #5925 Added tests to cover. Extracted existing test to place with similiar sessions tests
1 parent 2fde803 commit 65f7b61

File tree

3 files changed

+57
-24
lines changed

3 files changed

+57
-24
lines changed

app/Http/Middleware/StartSessionExtended.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
class StartSessionExtended extends Middleware
1515
{
1616
protected static array $pathPrefixesExcludedFromHistory = [
17-
'uploads/images/'
17+
'uploads/images/',
18+
'dist/',
19+
'manifest.json',
20+
'opensearch.xml',
1821
];
1922

2023
/**

tests/SessionTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
class SessionTest extends TestCase
6+
{
7+
public function test_secure_images_not_tracked_in_session_history()
8+
{
9+
config()->set('filesystems.images', 'local_secure');
10+
$this->asEditor();
11+
$page = $this->entities->page();
12+
$result = $this->files->uploadGalleryImageToPage($this, $page);
13+
$expectedPath = storage_path($result['path']);
14+
$this->assertFileExists($expectedPath);
15+
16+
$this->get('/books');
17+
$this->assertEquals(url('/books'), session()->previousUrl());
18+
19+
$resp = $this->get($result['path']);
20+
$resp->assertOk();
21+
$resp->assertHeader('Content-Type', 'image/png');
22+
23+
$this->assertEquals(url('/books'), session()->previousUrl());
24+
25+
if (file_exists($expectedPath)) {
26+
unlink($expectedPath);
27+
}
28+
}
29+
30+
public function test_pwa_manifest_is_not_tracked_in_session_history()
31+
{
32+
$this->asEditor()->get('/books');
33+
$this->get('/manifest.json');
34+
35+
$this->assertEquals(url('/books'), session()->previousUrl());
36+
}
37+
38+
public function test_dist_dir_access_is_not_tracked_in_session_history()
39+
{
40+
$this->asEditor()->get('/books');
41+
$this->get('/dist/sub/hello.txt');
42+
43+
$this->assertEquals(url('/books'), session()->previousUrl());
44+
}
45+
46+
public function test_opensearch_is_not_tracked_in_session_history()
47+
{
48+
$this->asEditor()->get('/books');
49+
$this->get('/opensearch.xml');
50+
51+
$this->assertEquals(url('/books'), session()->previousUrl());
52+
}
53+
}

tests/Uploads/ImageTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -429,29 +429,6 @@ public function test_system_images_remain_public_with_local_secure()
429429
}
430430
}
431431

432-
public function test_secure_images_not_tracked_in_session_history()
433-
{
434-
config()->set('filesystems.images', 'local_secure');
435-
$this->asEditor();
436-
$page = $this->entities->page();
437-
$result = $this->files->uploadGalleryImageToPage($this, $page);
438-
$expectedPath = storage_path($result['path']);
439-
$this->assertFileExists($expectedPath);
440-
441-
$this->get('/books');
442-
$this->assertEquals(url('/books'), session()->previousUrl());
443-
444-
$resp = $this->get($result['path']);
445-
$resp->assertOk();
446-
$resp->assertHeader('Content-Type', 'image/png');
447-
448-
$this->assertEquals(url('/books'), session()->previousUrl());
449-
450-
if (file_exists($expectedPath)) {
451-
unlink($expectedPath);
452-
}
453-
}
454-
455432
public function test_system_images_remain_public_with_local_secure_restricted()
456433
{
457434
config()->set('filesystems.images', 'local_secure_restricted');

0 commit comments

Comments
 (0)