1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-09-20 14:14:03 +00:00

Assert that TenantAssetController throws for scoped disks with a non-local parent

This commit is contained in:
lukinovec 2026-09-03 16:03:15 +02:00 committed by Samuel Stancl
parent 2cd514c781
commit e20085588b

View file

@ -120,7 +120,7 @@ test('the disk used for serving tenant assets is configurable', function () {
expect($response->getFile()->getPathname())->toBe($path); 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([ config([
'tenancy.identification.default_middleware' => InitializeTenancyByRequestData::class, 'tenancy.identification.default_middleware' => InitializeTenancyByRequestData::class,
// Add a disk that uses the s3 driver (= non-local disk). // 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', 'secret' => 'secret',
'bucket' => 'bucket', 'bucket' => 'bucket',
], ],
'filesystems.disks.scoped_remote' => [
'driver' => 'scoped',
'disk' => 'remote',
'prefix' => 'assets',
],
]); ]);
TenantAssetController::$publicDisk = 'remote'; TenantAssetController::$publicDisk = $publicDisk;
$tenant = Tenant::create(); $tenant = Tenant::create();
tenancy()->initialize($tenant); tenancy()->initialize($tenant);
$this->withoutExceptionHandling(); $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]); 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) { test('tenant asset controller throws when the disk used for serving assets is not tenant-aware', function (string $publicDisk, string $expectedMessage) {
$centralStoragePath = storage_path(); $centralStoragePath = storage_path();