Files
InvoiceShelf/tests/Feature/Admin/UpdateContainerizedTest.php
Darko Gjorgjijoski 6f45b58933 feat(updater): disable the in-app updater in containerized installs
Consume the injected CONTAINERIZED flag: expose it on /app/version, block the update endpoints + console command, and show a 'docker compose pull' panel instead of the updater.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 23:43:18 +02:00

49 lines
1.6 KiB
PHP

<?php
use App\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Laravel\getJson;
use function Pest\Laravel\postJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$user = User::find(1);
$this->withHeaders([
'company' => $user->companies()->first()->id,
]);
Sanctum::actingAs(
$user,
['*']
);
});
it('exposes the containerized flag from the app version endpoint', function () {
config(['invoiceshelf.containerized' => true]);
getJson('/api/v1/app/version')
->assertOk()
->assertJson(['containerized' => true]);
config(['invoiceshelf.containerized' => false]);
getJson('/api/v1/app/version')
->assertOk()
->assertJson(['containerized' => false]);
});
it('blocks the in-app updater endpoints when containerized', function () {
config(['invoiceshelf.containerized' => true]);
getJson('/api/v1/check/update')->assertForbidden();
postJson('/api/v1/update/download', ['version' => '2.4.0'])->assertForbidden();
postJson('/api/v1/update/unzip', ['path' => '/tmp/x.zip'])->assertForbidden();
postJson('/api/v1/update/copy', ['path' => '/tmp/x'])->assertForbidden();
postJson('/api/v1/update/delete')->assertForbidden();
postJson('/api/v1/update/migrate')->assertForbidden();
postJson('/api/v1/update/finish', ['installed' => '2.4.0', 'version' => '2.4.1'])->assertForbidden();
});