Release 2.3.0
A share can now hold a private text (a password, a key, a short note) with its files or on its own. The upload page's new "Private text" card takes up to 100 KB; the browser encrypts the text and sends it through the same chunk pipeline as a file, flagged is_text on share_files, so it gets the share's password, expiry, download limit and cleanup. The recipient sees the text only after pressing "Show text", which counts as their download, so a messenger link preview cannot use up a share limited to one download. The text is left out of the file list, the ZIP and the file counts; the admin dashboard marks shares that hold one with "Text". The website gains a Private text feature card and a fifth phone screenshot; every screenshot is retaken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
202813a1e6
commit
f9a7839ad3
@@ -290,6 +290,104 @@ test('a password share created before key wrapping still unlocks and downloads',
|
||||
expect($this->get(route('share.download.file', [$share, $file]))->streamedContent())->toBe('old content');
|
||||
});
|
||||
|
||||
test('a text-only share page shows Show text and keeps the plaintext out of the response', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare([], [], 'the secret note');
|
||||
|
||||
$response = $this->get(route('share.download', $share));
|
||||
|
||||
$response->assertOk()
|
||||
->assertSeeHtml('data-test="show-text"')
|
||||
->assertDontSee('the secret note');
|
||||
});
|
||||
|
||||
test('revealText returns the private text and counts one download', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare([], [], 'the secret note');
|
||||
|
||||
Livewire::test(ShareDownload::class, ['share' => $share])
|
||||
->call('revealText')
|
||||
->assertReturned('the secret note');
|
||||
|
||||
expect($share->fresh()->download_count)->toBe(1);
|
||||
});
|
||||
|
||||
test('a second reveal in the same window is not counted again', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare([], [], 'the secret note');
|
||||
$component = Livewire::test(ShareDownload::class, ['share' => $share]);
|
||||
$component->call('revealText');
|
||||
|
||||
$component->call('revealText')
|
||||
->assertReturned('the secret note');
|
||||
|
||||
expect($share->fresh()->download_count)->toBe(1);
|
||||
});
|
||||
|
||||
test('another session cannot open a text-only share whose one download was taken', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare([], ['max_downloads' => 1], 'the secret note');
|
||||
Livewire::test(ShareDownload::class, ['share' => $share])->call('revealText');
|
||||
$this->flushSession();
|
||||
|
||||
$response = $this->get(route('share.download', $share));
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('a password share\'s revealText returns null before unlocking and counts nothing', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare([], ['password' => 'let-me-in'], 'the secret note');
|
||||
|
||||
Livewire::test(ShareDownload::class, ['share' => $share])
|
||||
->call('revealText')
|
||||
->assertReturned(null);
|
||||
|
||||
expect($share->fresh()->download_count)->toBe(0);
|
||||
});
|
||||
|
||||
test('share.download.file for the text row returns 404', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare(
|
||||
[['file' => UploadedFile::fake()->createWithContent('notes.txt', 'file content'), 'relativePath' => null]],
|
||||
[],
|
||||
'the secret note',
|
||||
);
|
||||
|
||||
$response = $this->get(route('share.download.file', [$share, $share->textFile]));
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('the zip of a mixed share has only the files, not the private text', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare(
|
||||
[['file' => UploadedFile::fake()->createWithContent('notes.txt', 'file content'), 'relativePath' => null]],
|
||||
[],
|
||||
'the secret note',
|
||||
);
|
||||
$zipPath = tempnam(sys_get_temp_dir(), 'zip');
|
||||
|
||||
file_put_contents($zipPath, $this->get(route('share.download.all', $share))->streamedContent());
|
||||
|
||||
$zip = new ZipArchive;
|
||||
expect($zip->open($zipPath))->toBeTrue();
|
||||
expect($zip->numFiles)->toBe(1);
|
||||
expect($zip->getFromName('notes.txt'))->toBe('file content');
|
||||
expect($zip->locateName('text.txt'))->toBeFalse();
|
||||
$zip->close();
|
||||
unlink($zipPath);
|
||||
});
|
||||
|
||||
test('share.download.all on a text-only share returns 404', function () {
|
||||
Storage::fake('shares');
|
||||
$share = app(ShareService::class)->createShare([], [], 'the secret note');
|
||||
|
||||
$response = $this->get(route('share.download.all', $share));
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
/**
|
||||
* Helper to create a share with an actual encrypted file.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user