+
+ public function test_file_access_with_open_query_param_provides_inline_response_with_correct_content_type()
+ {
+ $page = $this->entities->page();
+ $this->asAdmin();
+ $fileName = 'upload_test_file.txt';
+
+ $upload = $this->files->uploadAttachmentFile($this, $fileName, $page->id);
+ $upload->assertStatus(200);
+ $attachment = Attachment::query()->orderBy('id', 'desc')->take(1)->first();
+
+ $attachmentGet = $this->get($attachment->getUrl(true));
+ // http-foundation/Response does some 'fixing' of responses to add charsets to text responses.
+ $attachmentGet->assertHeader('Content-Type', 'text/plain; charset=UTF-8');
+ $attachmentGet->assertHeader('Content-Disposition', 'inline; filename="upload_test_file.txt"');
+ $attachmentGet->assertHeader('X-Content-Type-Options', 'nosniff');
+
+ $this->files->deleteAllAttachmentFiles();
+ }
+
+ public function test_html_file_access_with_open_forces_plain_content_type()
+ {
+ $page = $this->entities->page();
+ $this->asAdmin();
+
+ $attachment = $this->files->uploadAttachmentDataToPage($this, $page, 'test_file.html', '<html></html><p>testing</p>', 'text/html');
+
+ $attachmentGet = $this->get($attachment->getUrl(true));
+ // http-foundation/Response does some 'fixing' of responses to add charsets to text responses.
+ $attachmentGet->assertHeader('Content-Type', 'text/plain; charset=UTF-8');
+ $attachmentGet->assertHeader('Content-Disposition', 'inline; filename="test_file.html"');
+
+ $this->files->deleteAllAttachmentFiles();
+ }
+
+ public function test_file_upload_works_when_local_secure_restricted_is_in_use()
+ {
+ config()->set('filesystems.attachments', 'local_secure_restricted');
+
+ $page = $this->entities->page();
+ $fileName = 'upload_test_file.txt';
+
+ $this->asAdmin();
+ $upload = $this->files->uploadAttachmentFile($this, $fileName, $page->id);
+ $upload->assertStatus(200);
+
+ $attachment = Attachment::query()->orderBy('id', 'desc')->where('uploaded_to', '=', $page->id)->first();
+ $this->assertFileExists(storage_path($attachment->path));
+ $this->files->deleteAllAttachmentFiles();
+ }