From e20085588b34c9f58661640fb1ccfe15149c3358 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 3 Sep 2026 16:03:15 +0200 Subject: [PATCH] Assert that TenantAssetController throws for scoped disks with a non-local parent --- tests/TenantAssetTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/TenantAssetTest.php b/tests/TenantAssetTest.php index 7741a6da..e1c0b630 100644 --- a/tests/TenantAssetTest.php +++ b/tests/TenantAssetTest.php @@ -120,7 +120,7 @@ test('the disk used for serving tenant assets is configurable', function () { expect($response->getFile()->getPathname())->toBe($path); }); -test('tenant asset controller throws when the configured disk is not local', function () { +test('tenant asset controller throws when the configured disk is not local', function (string $publicDisk) { config([ 'tenancy.identification.default_middleware' => InitializeTenancyByRequestData::class, // Add a disk that uses the s3 driver (= non-local disk). @@ -132,18 +132,26 @@ test('tenant asset controller throws when the configured disk is not local', fun 'secret' => 'secret', 'bucket' => 'bucket', ], + 'filesystems.disks.scoped_remote' => [ + 'driver' => 'scoped', + 'disk' => 'remote', + 'prefix' => 'assets', + ], ]); - TenantAssetController::$publicDisk = 'remote'; + TenantAssetController::$publicDisk = $publicDisk; $tenant = Tenant::create(); tenancy()->initialize($tenant); $this->withoutExceptionHandling(); - pest()->expectExceptionMessage('Disk [remote] is not a local disk.'); + pest()->expectExceptionMessage("Disk [$publicDisk] is not a local disk."); pest()->get(tenant_asset('foo.txt'), ['X-Tenant' => $tenant->id]); -}); +})->with([ + 'disk' => 'remote', + 'scoped disk' => 'scoped_remote', +]); test('tenant asset controller throws when the disk used for serving assets is not tenant-aware', function (string $publicDisk, string $expectedMessage) { $centralStoragePath = storage_path();