X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/859934d6a3f9c94298dee1f177b95f192f4a90b7..refs/pull/3245/head:/tests/Api/AttachmentsApiTest.php diff --git a/tests/Api/AttachmentsApiTest.php b/tests/Api/AttachmentsApiTest.php index 40624dcdf..bfa47343e 100644 --- a/tests/Api/AttachmentsApiTest.php +++ b/tests/Api/AttachmentsApiTest.php @@ -224,6 +224,29 @@ class AttachmentsApiTest extends TestCase unlink(storage_path($attachment->path)); } + public function test_attachment_not_visible_on_other_users_draft() + { + $this->actingAsApiAdmin(); + $editor = $this->getEditor(); + + /** @var Page $page */ + $page = Page::query()->first(); + $page->draft = true; + $page->owned_by = $editor; + $page->save(); + $this->regenEntityPermissions($page); + + $attachment = $this->createAttachmentForPage($page, [ + 'name' => 'my attachment', + 'path' => 'https://example.com', + 'order' => 1, + ]); + + $resp = $this->getJson("{$this->baseEndpoint}/{$attachment->id}"); + + $resp->assertStatus(404); + } + public function test_update_endpoint() { $this->actingAsApiAdmin(); @@ -325,6 +348,6 @@ class AttachmentsApiTest extends TestCase */ protected function getTestFile(string $fileName): UploadedFile { - return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', 55, null, true); + return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', null, true); } }