createTestPost($postAttributes); $attachment = Attachment::create([ 'board_id' => $this->board->id, 'post_id' => $postId, 'original_filename' => 'thumb.jpg', 'stored_filename' => 'stored-thumb.jpg', 'disk' => 'modules', 'path' => 'attachments/thumb.jpg', 'mime_type' => $mimeType, 'size' => 100, 'collection' => 'attachments', 'order' => 0, ]); $post = Post::with(['thumbnailAttachment', 'board'])->findOrFail($postId); return ['post' => $post, 'attachment' => $attachment]; } /** * @effects board_response_strings_unchanged */ #[Test] public function thumbnail_serializes_preview_url_with_board_slug(): void { ['post' => $post, 'attachment' => $attachment] = $this->createPostWithAttachment('image/jpeg'); $response = (new PostResource($post))->toArray(Request::create('/')); $this->assertSame( '/api/modules/sirsoft-board/boards/'.$this->board->slug.'/attachment/'.$attachment->hash.'/preview', $response['thumbnail'], ); } /** * @effects board_response_strings_unchanged */ #[Test] public function thumbnail_is_null_for_non_image_attachment(): void { ['post' => $post] = $this->createPostWithAttachment('application/pdf'); $response = (new PostResource($post))->toArray(Request::create('/')); $this->assertNull($response['thumbnail']); } /** * 비밀글의 썸네일 URL은 열람 권한이 없으면 방출되지 않아야 합니다 (KVE-2026-1894). * * 서빙은 막혀 있어 이미지가 보이지는 않지만, URL 에 실린 첨부 해시 자체가 * 목록·상세 응답으로 나가 있었다. 필드는 남기고 값만 가린다. * * @effects secret_post_thumbnail_hash_not_exposed */ #[Test] public function thumbnail_is_null_for_secret_post_without_permission(): void { ['post' => $post] = $this->createPostWithAttachment('image/jpeg', ['is_secret' => true]); $response = (new PostResource($post))->toArray(Request::create('/')); $this->assertArrayHasKey('thumbnail', $response, 'thumbnail 키 자체는 유지되어야 합니다.'); $this->assertNull($response['thumbnail']); } /** * 비밀글이 아니면 썸네일 URL이 그대로 유지되어야 합니다 (선택적 차단 회귀 방지). * * @effects secret_post_thumbnail_hash_not_exposed */ #[Test] public function thumbnail_is_preserved_for_non_secret_post(): void { ['post' => $post, 'attachment' => $attachment] = $this->createPostWithAttachment('image/jpeg'); $response = (new PostResource($post))->toArray(Request::create('/')); $this->assertSame( '/api/modules/sirsoft-board/boards/'.$this->board->slug.'/attachment/'.$attachment->hash.'/preview', $response['thumbnail'], ); } }