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

Assert that CreateStorageSymlinksAction cannot create symlinks for disks that are not in tenancy.filesystem.disks, i.e. aren't tenant-aware (regression test)

This commit is contained in:
lukinovec 2026-08-19 10:27:20 +02:00 committed by Samuel Stancl
parent 4e1fb850bc
commit b6e6aa634c

View file

@ -55,6 +55,30 @@ test('create storage symlinks action works', function (string $rootOverride, boo
'custom root_override' => ['%original_storage_path%/app/public/%tenant%/', true], 'custom root_override' => ['%original_storage_path%/app/public/%tenant%/', true],
]); ]);
test('create storage symlinks action fails for disks that are not tenant-aware', function () {
config([
'tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
],
// The public disk has both overrides configured, but it is not in
// tenancy.filesystem.disks, so the bootstrapper never scopes its root.
// Symlinking it would point every tenant's public path to the central disk root.
'tenancy.filesystem.disks' => ['local'],
'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/',
'tenancy.filesystem.url_override.public' => 'public-%tenant%',
]);
/** @var Tenant $tenant */
$tenant = Tenant::create();
(new CreateStorageSymlinksAction)($tenant);
expect(fn () => (new CreateStorageSymlinksAction)($tenant))
->toThrow(Exception::class, 'Disk public is not tenant-aware.');
expect(is_link(public_path('public-' . $tenant->getTenantKey())))->toBeFalse();
});
test('remove storage symlinks action works', function() { test('remove storage symlinks action works', function() {
config([ config([
'tenancy.bootstrappers' => [ 'tenancy.bootstrappers' => [