Apply Pint 1.29 formatting
The Laravel 13 upgrade pulled Pint 1.27.1 to 1.29.3, which changed the laravel preset's default rules. composer lint and the CI lint job fail without this, so it is required rather than cosmetic. Formatting only, applied by `vendor/bin/pint`. The rules that fired were fully_qualified_strict_types, ordered_imports, single_blank_line_at_eof, unary_operator_spaces, not_operator_with_successor_space, braces_position, single_line_empty_body, single_line_after_imports and no_extra_blank_lines. Kept separate from the upgrade commit to keep that diff reviewable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1ebd51248e
commit
9f929c7a78
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Concerns;
|
namespace App\Concerns;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
use Illuminate\Validation\Rules\Password;
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
trait PasswordValidationRules
|
trait PasswordValidationRules
|
||||||
@@ -9,7 +10,7 @@ trait PasswordValidationRules
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules used to validate passwords.
|
* Get the validation rules used to validate passwords.
|
||||||
*
|
*
|
||||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
* @return array<int, Rule|array<mixed>|string>
|
||||||
*/
|
*/
|
||||||
protected function passwordRules(): array
|
protected function passwordRules(): array
|
||||||
{
|
{
|
||||||
@@ -19,7 +20,7 @@ trait PasswordValidationRules
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules used to validate the current password.
|
* Get the validation rules used to validate the current password.
|
||||||
*
|
*
|
||||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
* @return array<int, Rule|array<mixed>|string>
|
||||||
*/
|
*/
|
||||||
protected function currentPasswordRules(): array
|
protected function currentPasswordRules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Services\FileEncryptionService;
|
|||||||
use App\Services\ShareService;
|
use App\Services\ShareService;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ class DownloadController extends Controller
|
|||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type' => $mimeType,
|
'Content-Type' => $mimeType,
|
||||||
'Content-Disposition' => \Symfony\Component\HttpFoundation\HeaderUtils::makeDisposition(
|
'Content-Disposition' => HeaderUtils::makeDisposition(
|
||||||
'attachment',
|
'attachment',
|
||||||
$shareFile->original_name,
|
$shareFile->original_name,
|
||||||
'download',
|
'download',
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class SecurityHeaders
|
|||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
*
|
||||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
* @param Closure(Request): (Response) $next
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Services\ShareService;
|
|||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Livewire\Attributes\Layout;
|
use Livewire\Attributes\Layout;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
use Livewire\WithFileUploads;
|
use Livewire\WithFileUploads;
|
||||||
|
|
||||||
#[Layout('layouts.app')]
|
#[Layout('layouts.app')]
|
||||||
@@ -14,7 +15,7 @@ class FileUploader extends Component
|
|||||||
{
|
{
|
||||||
use WithFileUploads;
|
use WithFileUploads;
|
||||||
|
|
||||||
/** @var array<int, \Livewire\Features\SupportFileUploads\TemporaryUploadedFile> */
|
/** @var array<int, TemporaryUploadedFile> */
|
||||||
public array $files = [];
|
public array $files = [];
|
||||||
|
|
||||||
/** @var array<int, string|null> */
|
/** @var array<int, string|null> */
|
||||||
|
|||||||
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@@ -11,7 +12,7 @@ use Laravel\Fortify\TwoFactorAuthenticatable;
|
|||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory, Notifiable, TwoFactorAuthenticatable;
|
use HasFactory, Notifiable, TwoFactorAuthenticatable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class ShareService
|
|||||||
{
|
{
|
||||||
if ($share->isPasswordProtected()) {
|
if ($share->isPasswordProtected()) {
|
||||||
if (! $password) {
|
if (! $password) {
|
||||||
throw new \RuntimeException('Password required for this share');
|
throw new RuntimeException('Password required for this share');
|
||||||
}
|
}
|
||||||
|
|
||||||
return bin2hex($this->encryptionService->deriveKey($password, $share->encryption_salt));
|
return bin2hex($this->encryptionService->deriveKey($password, $share->encryption_salt));
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Providers\AppServiceProvider;
|
||||||
|
use App\Providers\FortifyServiceProvider;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
App\Providers\AppServiceProvider::class,
|
AppServiceProvider::class,
|
||||||
App\Providers\FortifyServiceProvider::class,
|
FortifyServiceProvider::class,
|
||||||
];
|
];
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -62,7 +64,7 @@ return [
|
|||||||
'providers' => [
|
'providers' => [
|
||||||
'users' => [
|
'users' => [
|
||||||
'driver' => 'eloquent',
|
'driver' => 'eloquent',
|
||||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
'model' => env('AUTH_MODEL', User::class),
|
||||||
],
|
],
|
||||||
|
|
||||||
// 'users' => [
|
// 'users' => [
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Pdo\Mysql;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ return [
|
|||||||
'strict' => true,
|
'strict' => true,
|
||||||
'engine' => null,
|
'engine' => null,
|
||||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||||
]) : [],
|
]) : [],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ return [
|
|||||||
'strict' => true,
|
'strict' => true,
|
||||||
'engine' => null,
|
'engine' => null,
|
||||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||||
]) : [],
|
]) : [],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
* @extends Factory<User>
|
||||||
*/
|
*/
|
||||||
class UserFactory extends Factory
|
class UserFactory extends Factory
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\Admin\AdminDashboard;
|
||||||
use App\Models\Share;
|
use App\Models\Share;
|
||||||
use App\Models\ShareFile;
|
use App\Models\ShareFile;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -52,7 +53,7 @@ test('admin can delete share', function () {
|
|||||||
$shareId = $share->id;
|
$shareId = $share->id;
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminDashboard::class)
|
->test(AdminDashboard::class)
|
||||||
->call('deleteShare', $shareId);
|
->call('deleteShare', $shareId);
|
||||||
|
|
||||||
expect(Share::query()->find($shareId))->toBeNull();
|
expect(Share::query()->find($shareId))->toBeNull();
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\Admin\AdminSettings;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
|
|
||||||
test('admin settings requires authentication', function () {
|
test('admin settings requires authentication', function () {
|
||||||
@@ -29,10 +31,10 @@ test('admin can access settings page', function () {
|
|||||||
test('admin can save settings', function () {
|
test('admin can save settings', function () {
|
||||||
$admin = User::query()->where('is_admin', true)->first();
|
$admin = User::query()->where('is_admin', true)->first();
|
||||||
|
|
||||||
$phpMaxMb = \App\Livewire\Admin\AdminSettings::phpMaxUploadMb();
|
$phpMaxMb = AdminSettings::phpMaxUploadMb();
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminSettings::class)
|
->test(AdminSettings::class)
|
||||||
->set('maxFileSize', min(200, $phpMaxMb))
|
->set('maxFileSize', min(200, $phpMaxMb))
|
||||||
->set('maxStorageQuota', 50)
|
->set('maxStorageQuota', 50)
|
||||||
->set('maxFilesPerShare', 100)
|
->set('maxFilesPerShare', 100)
|
||||||
@@ -50,10 +52,10 @@ test('admin can save settings', function () {
|
|||||||
|
|
||||||
test('admin can set system password', function () {
|
test('admin can set system password', function () {
|
||||||
$admin = User::query()->where('is_admin', true)->first();
|
$admin = User::query()->where('is_admin', true)->first();
|
||||||
$phpMaxMb = \App\Livewire\Admin\AdminSettings::phpMaxUploadMb();
|
$phpMaxMb = AdminSettings::phpMaxUploadMb();
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminSettings::class)
|
->test(AdminSettings::class)
|
||||||
->set('maxFileSize', $phpMaxMb)
|
->set('maxFileSize', $phpMaxMb)
|
||||||
->set('systemPassword', 'new-system-password')
|
->set('systemPassword', 'new-system-password')
|
||||||
->call('saveSettings')
|
->call('saveSettings')
|
||||||
@@ -61,7 +63,7 @@ test('admin can set system password', function () {
|
|||||||
|
|
||||||
$storedPassword = Setting::get('system_password');
|
$storedPassword = Setting::get('system_password');
|
||||||
expect($storedPassword)->not->toBeNull();
|
expect($storedPassword)->not->toBeNull();
|
||||||
expect(\Illuminate\Support\Facades\Hash::check('new-system-password', $storedPassword))->toBeTrue();
|
expect(Hash::check('new-system-password', $storedPassword))->toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('admin can clear system password', function () {
|
test('admin can clear system password', function () {
|
||||||
@@ -70,7 +72,7 @@ test('admin can clear system password', function () {
|
|||||||
Setting::set('system_password', bcrypt('existing-password'));
|
Setting::set('system_password', bcrypt('existing-password'));
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminSettings::class)
|
->test(AdminSettings::class)
|
||||||
->call('clearSystemPassword')
|
->call('clearSystemPassword')
|
||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
@@ -79,14 +81,14 @@ test('admin can clear system password', function () {
|
|||||||
|
|
||||||
test('settings page loads existing values', function () {
|
test('settings page loads existing values', function () {
|
||||||
$admin = User::query()->where('is_admin', true)->first();
|
$admin = User::query()->where('is_admin', true)->first();
|
||||||
$phpMaxMb = \App\Livewire\Admin\AdminSettings::phpMaxUploadMb();
|
$phpMaxMb = AdminSettings::phpMaxUploadMb();
|
||||||
$testSize = min(40, $phpMaxMb);
|
$testSize = min(40, $phpMaxMb);
|
||||||
|
|
||||||
Setting::set('max_file_size', $testSize * 1024 * 1024);
|
Setting::set('max_file_size', $testSize * 1024 * 1024);
|
||||||
Setting::set('max_files_per_share', 75);
|
Setting::set('max_files_per_share', 75);
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminSettings::class)
|
->test(AdminSettings::class)
|
||||||
->assertSet('maxFileSize', $testSize)
|
->assertSet('maxFileSize', $testSize)
|
||||||
->assertSet('maxFilesPerShare', 75);
|
->assertSet('maxFilesPerShare', 75);
|
||||||
});
|
});
|
||||||
@@ -95,7 +97,7 @@ test('settings validation rejects invalid values', function () {
|
|||||||
$admin = User::query()->where('is_admin', true)->first();
|
$admin = User::query()->where('is_admin', true)->first();
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminSettings::class)
|
->test(AdminSettings::class)
|
||||||
->set('maxFileSize', 0)
|
->set('maxFileSize', 0)
|
||||||
->set('maxStorageQuota', 0)
|
->set('maxStorageQuota', 0)
|
||||||
->call('saveSettings')
|
->call('saveSettings')
|
||||||
|
|||||||
@@ -66,4 +66,4 @@ test('users can logout', function () {
|
|||||||
$response->assertRedirect(route('home'));
|
$response->assertRedirect(route('home'));
|
||||||
|
|
||||||
$this->assertGuest();
|
$this->assertGuest();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -64,4 +64,4 @@ test('already verified user visiting verification link is redirected without fir
|
|||||||
|
|
||||||
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
|
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
|
||||||
Event::assertNotDispatched(Verified::class);
|
Event::assertNotDispatched(Verified::class);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ test('confirm password screen can be rendered', function () {
|
|||||||
$response = $this->actingAs($user)->get(route('password.confirm'));
|
$response = $this->actingAs($user)->get(route('password.confirm'));
|
||||||
|
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,4 +57,4 @@ test('password can be reset with valid token', function () {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ test('two factor challenge can be rendered', function () {
|
|||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'password' => 'password',
|
'password' => 'password',
|
||||||
])->assertRedirect(route('two-factor.login'));
|
])->assertRedirect(route('two-factor.login'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ test('authenticated users can visit the dashboard', function () {
|
|||||||
|
|
||||||
$response = $this->get(route('dashboard'));
|
$response = $this->get(route('dashboard'));
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\FileUploader;
|
||||||
|
use App\Livewire\SystemPasswordPrompt;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\Share;
|
use App\Models\Share;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
@@ -34,7 +36,7 @@ test('file upload creates share', function () {
|
|||||||
|
|
||||||
$file = UploadedFile::fake()->create('document.pdf', 1024);
|
$file = UploadedFile::fake()->create('document.pdf', 1024);
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\FileUploader::class)
|
Livewire::test(FileUploader::class)
|
||||||
->set('files', [$file])
|
->set('files', [$file])
|
||||||
->call('createShare')
|
->call('createShare')
|
||||||
->assertRedirectContains('/share/');
|
->assertRedirectContains('/share/');
|
||||||
@@ -51,7 +53,7 @@ test('file upload with password creates password-protected share', function () {
|
|||||||
|
|
||||||
$file = UploadedFile::fake()->create('secret.txt', 512);
|
$file = UploadedFile::fake()->create('secret.txt', 512);
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\FileUploader::class)
|
Livewire::test(FileUploader::class)
|
||||||
->set('files', [$file])
|
->set('files', [$file])
|
||||||
->set('usePassword', true)
|
->set('usePassword', true)
|
||||||
->set('password', 'my-password')
|
->set('password', 'my-password')
|
||||||
@@ -67,7 +69,7 @@ test('file upload with expiration sets expires_at', function () {
|
|||||||
|
|
||||||
$file = UploadedFile::fake()->create('file.txt', 256);
|
$file = UploadedFile::fake()->create('file.txt', 256);
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\FileUploader::class)
|
Livewire::test(FileUploader::class)
|
||||||
->set('files', [$file])
|
->set('files', [$file])
|
||||||
->set('expiration', '24h')
|
->set('expiration', '24h')
|
||||||
->call('createShare')
|
->call('createShare')
|
||||||
@@ -82,7 +84,7 @@ test('file upload with max downloads sets limit', function () {
|
|||||||
|
|
||||||
$file = UploadedFile::fake()->create('file.txt', 256);
|
$file = UploadedFile::fake()->create('file.txt', 256);
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\FileUploader::class)
|
Livewire::test(FileUploader::class)
|
||||||
->set('files', [$file])
|
->set('files', [$file])
|
||||||
->set('maxDownloads', 5)
|
->set('maxDownloads', 5)
|
||||||
->call('createShare')
|
->call('createShare')
|
||||||
@@ -93,7 +95,7 @@ test('file upload with max downloads sets limit', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('file upload requires at least one file', function () {
|
test('file upload requires at least one file', function () {
|
||||||
Livewire::test(\App\Livewire\FileUploader::class)
|
Livewire::test(FileUploader::class)
|
||||||
->set('files', [])
|
->set('files', [])
|
||||||
->call('createShare')
|
->call('createShare')
|
||||||
->assertHasErrors(['files']);
|
->assertHasErrors(['files']);
|
||||||
@@ -106,7 +108,7 @@ test('file upload blocks when storage is full', function () {
|
|||||||
|
|
||||||
$file = UploadedFile::fake()->create('file.txt', 1);
|
$file = UploadedFile::fake()->create('file.txt', 1);
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\FileUploader::class)
|
Livewire::test(FileUploader::class)
|
||||||
->set('files', [$file])
|
->set('files', [$file])
|
||||||
->call('createShare')
|
->call('createShare')
|
||||||
->assertHasErrors(['files']);
|
->assertHasErrors(['files']);
|
||||||
@@ -115,7 +117,7 @@ test('file upload blocks when storage is full', function () {
|
|||||||
test('system password prompt verifies correct password', function () {
|
test('system password prompt verifies correct password', function () {
|
||||||
Setting::set('system_password', bcrypt('system-secret'));
|
Setting::set('system_password', bcrypt('system-secret'));
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\SystemPasswordPrompt::class)
|
Livewire::test(SystemPasswordPrompt::class)
|
||||||
->set('password', 'system-secret')
|
->set('password', 'system-secret')
|
||||||
->call('verify')
|
->call('verify')
|
||||||
->assertRedirect(route('upload'));
|
->assertRedirect(route('upload'));
|
||||||
@@ -124,7 +126,7 @@ test('system password prompt verifies correct password', function () {
|
|||||||
test('system password prompt rejects incorrect password', function () {
|
test('system password prompt rejects incorrect password', function () {
|
||||||
Setting::set('system_password', bcrypt('system-secret'));
|
Setting::set('system_password', bcrypt('system-secret'));
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\SystemPasswordPrompt::class)
|
Livewire::test(SystemPasswordPrompt::class)
|
||||||
->set('password', 'wrong')
|
->set('password', 'wrong')
|
||||||
->call('verify')
|
->call('verify')
|
||||||
->assertHasErrors(['password']);
|
->assertHasErrors(['password']);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\Admin\AdminSettings;
|
||||||
use App\Livewire\FileUploader;
|
use App\Livewire\FileUploader;
|
||||||
use App\Livewire\ShareDownload;
|
use App\Livewire\ShareDownload;
|
||||||
use App\Models\Share;
|
use App\Models\Share;
|
||||||
@@ -193,10 +194,10 @@ test('content disposition handles special characters in filename', function () {
|
|||||||
test('svg upload is rejected for site logo', function () {
|
test('svg upload is rejected for site logo', function () {
|
||||||
$admin = User::query()->where('is_admin', true)->first();
|
$admin = User::query()->where('is_admin', true)->first();
|
||||||
|
|
||||||
$phpMaxMb = \App\Livewire\Admin\AdminSettings::phpMaxUploadMb();
|
$phpMaxMb = AdminSettings::phpMaxUploadMb();
|
||||||
|
|
||||||
Livewire::actingAs($admin)
|
Livewire::actingAs($admin)
|
||||||
->test(\App\Livewire\Admin\AdminSettings::class)
|
->test(AdminSettings::class)
|
||||||
->set('maxFileSize', $phpMaxMb)
|
->set('maxFileSize', $phpMaxMb)
|
||||||
->set('siteLogo', UploadedFile::fake()->create('logo.svg', 100, 'image/svg+xml'))
|
->set('siteLogo', UploadedFile::fake()->create('logo.svg', 100, 'image/svg+xml'))
|
||||||
->call('saveSettings')
|
->call('saveSettings')
|
||||||
|
|||||||
@@ -36,4 +36,4 @@ test('correct password must be provided to update password', function () {
|
|||||||
->call('updatePassword');
|
->call('updatePassword');
|
||||||
|
|
||||||
$response->assertHasErrors(['current_password']);
|
$response->assertHasErrors(['current_password']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -72,4 +72,4 @@ test('correct password must be provided to delete account', function () {
|
|||||||
$response->assertHasErrors(['password']);
|
$response->assertHasErrors(['password']);
|
||||||
|
|
||||||
expect($user->fresh())->not->toBeNull();
|
expect($user->fresh())->not->toBeNull();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,4 +67,4 @@ test('two factor authentication disabled when confirmation abandoned between req
|
|||||||
'two_factor_secret' => null,
|
'two_factor_secret' => null,
|
||||||
'two_factor_recovery_codes' => null,
|
'two_factor_recovery_codes' => null,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\SetupWizard;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
|
|
||||||
@@ -12,14 +13,14 @@ test('setup wizard renders when no admin exists', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('setup wizard redirects to upload when admin already exists', function () {
|
test('setup wizard redirects to upload when admin already exists', function () {
|
||||||
Livewire::test(\App\Livewire\SetupWizard::class)
|
Livewire::test(SetupWizard::class)
|
||||||
->assertRedirect(route('upload'));
|
->assertRedirect(route('upload'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('setup wizard creates admin user', function () {
|
test('setup wizard creates admin user', function () {
|
||||||
User::query()->where('is_admin', true)->delete();
|
User::query()->where('is_admin', true)->delete();
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\SetupWizard::class)
|
Livewire::test(SetupWizard::class)
|
||||||
->set('name', 'Admin User')
|
->set('name', 'Admin User')
|
||||||
->set('email', 'admin@example.com')
|
->set('email', 'admin@example.com')
|
||||||
->set('password', 'password123')
|
->set('password', 'password123')
|
||||||
@@ -40,7 +41,7 @@ test('setup wizard creates admin user', function () {
|
|||||||
test('setup wizard validates required fields', function () {
|
test('setup wizard validates required fields', function () {
|
||||||
User::query()->where('is_admin', true)->delete();
|
User::query()->where('is_admin', true)->delete();
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\SetupWizard::class)
|
Livewire::test(SetupWizard::class)
|
||||||
->set('name', '')
|
->set('name', '')
|
||||||
->set('email', '')
|
->set('email', '')
|
||||||
->set('password', '')
|
->set('password', '')
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\ShareDownload;
|
||||||
use App\Models\Share;
|
use App\Models\Share;
|
||||||
use App\Services\FileEncryptionService;
|
use App\Services\FileEncryptionService;
|
||||||
use App\Services\ShareService;
|
use App\Services\ShareService;
|
||||||
@@ -49,7 +50,7 @@ test('password verification works for protected share', function () {
|
|||||||
|
|
||||||
$share = createShareWithFile('my-password');
|
$share = createShareWithFile('my-password');
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\ShareDownload::class, ['share' => $share])
|
Livewire::test(ShareDownload::class, ['share' => $share])
|
||||||
->assertSet('authenticated', false)
|
->assertSet('authenticated', false)
|
||||||
->set('password', 'my-password')
|
->set('password', 'my-password')
|
||||||
->call('verifyPassword')
|
->call('verifyPassword')
|
||||||
@@ -62,7 +63,7 @@ test('wrong password is rejected', function () {
|
|||||||
|
|
||||||
$share = createShareWithFile('my-password');
|
$share = createShareWithFile('my-password');
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\ShareDownload::class, ['share' => $share])
|
Livewire::test(ShareDownload::class, ['share' => $share])
|
||||||
->set('password', 'wrong-password')
|
->set('password', 'wrong-password')
|
||||||
->call('verifyPassword')
|
->call('verifyPassword')
|
||||||
->assertSet('authenticated', false)
|
->assertSet('authenticated', false)
|
||||||
@@ -74,7 +75,7 @@ test('non-password share shows files directly', function () {
|
|||||||
|
|
||||||
$share = createShareWithFile();
|
$share = createShareWithFile();
|
||||||
|
|
||||||
Livewire::test(\App\Livewire\ShareDownload::class, ['share' => $share])
|
Livewire::test(ShareDownload::class, ['share' => $share])
|
||||||
->assertSet('authenticated', true);
|
->assertSet('authenticated', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ test('zip download produces a valid archive', function () {
|
|||||||
|
|
||||||
$zipPath = $response->getFile()->getPathname();
|
$zipPath = $response->getFile()->getPathname();
|
||||||
|
|
||||||
$zip = new \ZipArchive;
|
$zip = new ZipArchive;
|
||||||
$result = $zip->open($zipPath);
|
$result = $zip->open($zipPath);
|
||||||
|
|
||||||
expect($result)->toBe(true);
|
expect($result)->toBe(true);
|
||||||
|
|||||||
+7
-3
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Test Case
|
| Test Case
|
||||||
@@ -11,11 +15,11 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pest()->extend(Tests\TestCase::class)
|
pest()->extend(TestCase::class)
|
||||||
->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
|
->use(RefreshDatabase::class)
|
||||||
->beforeEach(function () {
|
->beforeEach(function () {
|
||||||
// EnsureSetupComplete middleware redirects to /setup unless an admin exists.
|
// EnsureSetupComplete middleware redirects to /setup unless an admin exists.
|
||||||
\App\Models\User::factory()->admin()->create(['email' => 'admin-setup@test.com']);
|
User::factory()->admin()->create(['email' => 'admin-setup@test.com']);
|
||||||
})
|
})
|
||||||
->in('Feature');
|
->in('Feature');
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
test('that true is true', function () {
|
test('that true is true', function () {
|
||||||
expect(true)->toBeTrue();
|
expect(true)->toBeTrue();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Services\FileEncryptionService;
|
use App\Services\FileEncryptionService;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->service = new FileEncryptionService;
|
$this->service = new FileEncryptionService;
|
||||||
@@ -119,7 +120,7 @@ test('decrypt file stream returns streamed response', function () {
|
|||||||
|
|
||||||
$response = $this->service->decryptFileStream($encryptedPath, $key, 'test.txt', 'text/plain');
|
$response = $this->service->decryptFileStream($encryptedPath, $key, 'test.txt', 'text/plain');
|
||||||
|
|
||||||
expect($response)->toBeInstanceOf(Symfony\Component\HttpFoundation\StreamedResponse::class);
|
expect($response)->toBeInstanceOf(StreamedResponse::class);
|
||||||
expect($response->headers->get('Content-Type'))->toBe('text/plain');
|
expect($response->headers->get('Content-Type'))->toBe('text/plain');
|
||||||
expect($response->headers->get('Content-Disposition'))->toContain('test.txt');
|
expect($response->headers->get('Content-Disposition'))->toContain('test.txt');
|
||||||
});
|
});
|
||||||
@@ -219,7 +220,6 @@ test('wrong key on chunked file throws exception', function () {
|
|||||||
$this->service->decryptFile($encryptedPath, $wrongKey);
|
$this->service->decryptFile($encryptedPath, $wrongKey);
|
||||||
})->throws(RuntimeException::class, 'Decryption failed');
|
})->throws(RuntimeException::class, 'Decryption failed');
|
||||||
|
|
||||||
|
|
||||||
test('decrypt file stream with file size sets content-length header', function () {
|
test('decrypt file stream with file size sets content-length header', function () {
|
||||||
$sourcePath = $this->tempDir.'/source.txt';
|
$sourcePath = $this->tempDir.'/source.txt';
|
||||||
$encryptedPath = $this->tempDir.'/encrypted.enc';
|
$encryptedPath = $this->tempDir.'/encrypted.enc';
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ use App\Models\Setting;
|
|||||||
use App\Models\Share;
|
use App\Models\Share;
|
||||||
use App\Models\ShareFile;
|
use App\Models\ShareFile;
|
||||||
use App\Services\ShareService;
|
use App\Services\ShareService;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
pest()->extend(Tests\TestCase::class)
|
pest()->extend(TestCase::class)
|
||||||
->use(Illuminate\Foundation\Testing\RefreshDatabase::class);
|
->use(RefreshDatabase::class);
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
Storage::fake('shares');
|
Storage::fake('shares');
|
||||||
@@ -42,7 +45,7 @@ test('create share with password does not store encryption key', function () {
|
|||||||
|
|
||||||
expect($share->password)->not->toBeNull();
|
expect($share->password)->not->toBeNull();
|
||||||
expect($share->encryption_key)->toBeNull();
|
expect($share->encryption_key)->toBeNull();
|
||||||
expect(\Illuminate\Support\Facades\Hash::check('my-password', $share->password))->toBeTrue();
|
expect(Hash::check('my-password', $share->password))->toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create share with options sets expiration and max downloads', function () {
|
test('create share with options sets expiration and max downloads', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user