56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Deployment;
|
|
|
|
use Tests\TestCase;
|
|
|
|
class WebProcessOwnershipTest extends TestCase
|
|
{
|
|
public function test_container_entrypoint_runs_laravel_maintenance_as_web_user(): void
|
|
{
|
|
$entrypoint = file_get_contents(base_path('deploy/entrypoint.sh'));
|
|
|
|
$this->assertIsString($entrypoint);
|
|
$this->assertStringContainsString(
|
|
'runuser -u www-data -- php artisan "$@"',
|
|
$entrypoint
|
|
);
|
|
$this->assertStringContainsString(
|
|
'run_artisan_as_web local-bootstrap:update --no-ansi',
|
|
$entrypoint
|
|
);
|
|
$this->assertStringContainsString('assert_web_writable', $entrypoint);
|
|
$this->assertDoesNotMatchRegularExpression('/^\s*php artisan /m', $entrypoint);
|
|
}
|
|
|
|
public function test_local_worker_healthcheck_and_initialization_use_web_user(): void
|
|
{
|
|
$compose = file_get_contents(base_path('docker-compose.local.yml'));
|
|
$initializer = file_get_contents(base_path('deploy/local-init.sh'));
|
|
|
|
$this->assertIsString($compose);
|
|
$this->assertStringContainsString(
|
|
'test: ["CMD", "jiangling-healthcheck"]',
|
|
$compose
|
|
);
|
|
$this->assertMatchesRegularExpression(
|
|
'/snapshot_worker:.*?user: www-data/s',
|
|
$compose
|
|
);
|
|
|
|
$this->assertIsString($initializer);
|
|
$this->assertStringContainsString(
|
|
'exec -T -u www-data app',
|
|
$initializer
|
|
);
|
|
$this->assertStringContainsString(
|
|
'php artisan local-bootstrap:update --no-ansi',
|
|
$initializer
|
|
);
|
|
$this->assertDoesNotMatchRegularExpression(
|
|
'/exec -T app\s+(?:\\\\\s*)?php artisan/',
|
|
$initializer
|
|
);
|
|
}
|
|
}
|