+ $galleryFile = $this->files->uploadedImage('my-system-test-restricted-upload.png');
+ $expectedPath = public_path('uploads/images/system/' . date('Y-m') . '/my-system-test-restricted-upload.png');
+
+ $upload = $this->call('POST', '/settings/customization', [], [], ['app_logo' => $galleryFile], []);
+ $upload->assertRedirect('/settings/customization');
+
+ $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);
+
+ if (file_exists($expectedPath)) {
+ unlink($expectedPath);
+ }
+ }
+
+ public function test_secure_restricted_images_inaccessible_without_relation_permission()
+ {
+ config()->set('filesystems.images', 'local_secure_restricted');
+ $this->asEditor();
+ $galleryFile = $this->files->uploadedImage('my-secure-restricted-test-upload.png');
+ $page = $this->entities->page();
+
+ $upload = $this->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $galleryFile], []);
+ $upload->assertStatus(200);
+ $expectedUrl = url('uploads/images/gallery/' . date('Y-m') . '/my-secure-restricted-test-upload.png');
+ $expectedPath = storage_path('uploads/images/gallery/' . date('Y-m') . '/my-secure-restricted-test-upload.png');
+
+ $this->get($expectedUrl)->assertOk();
+
+ $this->permissions->setEntityPermissions($page, [], []);
+
+ $resp = $this->get($expectedUrl);
+ $resp->assertNotFound();
+
+ if (file_exists($expectedPath)) {
+ unlink($expectedPath);
+ }
+ }
+
+ public function test_thumbnail_path_handled_by_secure_restricted_images()
+ {
+ config()->set('filesystems.images', 'local_secure_restricted');
+ $this->asEditor();
+ $galleryFile = $this->files->uploadedImage('my-secure-restricted-thumb-test-test.png');
+ $page = $this->entities->page();
+
+ $upload = $this->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $galleryFile], []);
+ $upload->assertStatus(200);
+ $expectedUrl = url('uploads/images/gallery/' . date('Y-m') . '/thumbs-150-150/my-secure-restricted-thumb-test-test.png');
+ $expectedPath = storage_path('uploads/images/gallery/' . date('Y-m') . '/my-secure-restricted-thumb-test-test.png');
+
+ $this->get($expectedUrl)->assertOk();
+
+ $this->permissions->setEntityPermissions($page, [], []);
+
+ $resp = $this->get($expectedUrl);
+ $resp->assertNotFound();
+
+ if (file_exists($expectedPath)) {
+ unlink($expectedPath);
+ }
+ }
+
+ public function test_secure_restricted_image_access_controlled_in_exports()
+ {
+ config()->set('filesystems.images', 'local_secure_restricted');
+ $this->asEditor();
+ $galleryFile = $this->files->uploadedImage('my-secure-restricted-export-test.png');
+
+ $pageA = $this->entities->page();
+ $pageB = $this->entities->page();
+ $expectedPath = storage_path('uploads/images/gallery/' . date('Y-m') . '/my-secure-restricted-export-test.png');
+
+ $upload = $this->asEditor()->call('POST', '/images/gallery', ['uploaded_to' => $pageA->id], [], ['file' => $galleryFile], []);
+ $upload->assertOk();