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

Exercise the valid asset path before testing traversal

Request photo.jpg and assert success before asserting rejection of ../media-originals/photo.jpg

(addresses https://github.com/archtechx/tenancy/pull/1479#pullrequestreview-4984403598)
This commit is contained in:
lukinovec 2026-08-21 16:07:01 +02:00 committed by Samuel Stancl
parent e70057e3ba
commit 802022a926

View file

@ -404,6 +404,10 @@ test('tenant asset controller throws an exception when accessing a file in a dir
Storage::disk('media')->put('photo.jpg', 'public file'); Storage::disk('media')->put('photo.jpg', 'public file');
pest()->get(tenant_asset('photo.jpg'), [
'X-Tenant' => $tenant->id,
])->assertSuccessful();
// A directory next to the asset root, e.g. one holding files that shouldn't be served // A directory next to the asset root, e.g. one holding files that shouldn't be served
mkdir($privateDirectory = storage_path('app/media-originals'), recursive: true); mkdir($privateDirectory = storage_path('app/media-originals'), recursive: true);
file_put_contents($privateDirectory . '/photo.jpg', 'private file'); file_put_contents($privateDirectory . '/photo.jpg', 'private file');