An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(database): queue starts and resolve credentials securely
Andras Bacsaif49c330d9d15
diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.phpindex 341e1a02e0..077e95080f 100644--- a/app/Actions/Database/StartClickhouse.php+++ b/app/Actions/Database/StartClickhouse.php@@ -3,12 +3,14 @@namespace App\Actions\Database;use App\Models\StandaloneClickhouse;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartClickhouse{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneClickhouse $database;@@ -20,7 +22,7 @@ class StartClickhouseprivate string $resolvedClickhousePassword;- public function handle(StandaloneClickhouse $database)+ public function handle(StandaloneClickhouse $database, ?Activity $activity = null){$this->database = $database;@@ -113,7 +115,7 @@ class StartClickhouse$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartDatabase.php b/app/Actions/Database/StartDatabase.phpindex 4b55b0c1df..86286a154b 100644--- a/app/Actions/Database/StartDatabase.php+++ b/app/Actions/Database/StartDatabase.php@@ -2,6 +2,9 @@namespace App\Actions\Database;+use App\Enums\ActivityTypes;+use App\Enums\ProcessStatus;+use App\Jobs\DatabaseStartJob;use App\Models\StandaloneClickhouse;use App\Models\StandaloneDragonfly;use App\Models\StandaloneKeydb;@@ -12,6 +15,7 @@ use App\Models\StandalonePostgresql;use App\Models\StandaloneRedis;use Lorisleiva\Actions\Concerns\AsAction;use Lorisleiva\Actions\Decorators\JobDecorator;+use Spatie\Activitylog\Models\Activity;class StartDatabase{@@ -22,38 +26,33 @@ class StartDatabase$job->onQueue(deployment_queue());}- public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database)+ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database): Activity|string{$server = $database->destination->server;if (! $server->isFunctional()) {return 'Server is not functional';}- switch ($database->getMorphClass()) {- case StandalonePostgresql::class:- $activity = StartPostgresql::run($database);- break;- case StandaloneRedis::class:- $activity = StartRedis::run($database);- break;- case StandaloneMongodb::class:- $activity = StartMongodb::run($database);- break;- case StandaloneMysql::class:- $activity = StartMysql::run($database);- break;- case StandaloneMariadb::class:- $activity = StartMariadb::run($database);- break;- case StandaloneKeydb::class:- $activity = StartKeydb::run($database);- break;- case StandaloneDragonfly::class:- $activity = StartDragonfly::run($database);- break;- case StandaloneClickhouse::class:- $activity = StartClickhouse::run($database);- break;- }++ $activity = activity()+ ->withProperties([+ 'server_uuid' => $server->uuid,+ 'type' => ActivityTypes::INLINE->value,+ 'type_uuid' => $database->uuid,+ 'status' => ProcessStatus::QUEUED->value,+ 'team_id' => $server->team_id,+ 'operation' => 'database-start',+ ])+ ->performedOn($database)+ ->event(ActivityTypes::INLINE->value)+ ->log('[]');++ DatabaseStartJob::dispatch(+ $database->getMorphClass(),+ (int) $database->getKey(),+ (int) $database->team()->id,+ (int) $activity->getKey(),+ );+if ($database->is_public && $database->public_port) {StartDatabaseProxy::dispatch($database);}diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.phpindex 1969ea8b81..b76e90ce49 100644--- a/app/Actions/Database/StartDragonfly.php+++ b/app/Actions/Database/StartDragonfly.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandaloneDragonfly;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartDragonfly{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneDragonfly $database;@@ -22,7 +24,7 @@ class StartDragonflyprivate string $resolvedRedisPassword;- public function handle(StandaloneDragonfly $database)+ public function handle(StandaloneDragonfly $database, ?Activity $activity = null){$this->database = $database;@@ -198,7 +200,7 @@ class StartDragonfly$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function buildStartCommand(): stringdiff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.phpindex f353e67ebf..a355617ed7 100644--- a/app/Actions/Database/StartKeydb.php+++ b/app/Actions/Database/StartKeydb.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandaloneKeydb;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartKeydb{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneKeydb $database;@@ -22,7 +24,7 @@ class StartKeydbprivate string $resolvedRedisPassword;- public function handle(StandaloneKeydb $database)+ public function handle(StandaloneKeydb $database, ?Activity $activity = null){$this->database = $database;@@ -216,7 +218,7 @@ class StartKeydb$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.phpindex 09512ee7b3..a05da25efd 100644--- a/app/Actions/Database/StartMariadb.php+++ b/app/Actions/Database/StartMariadb.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandaloneMariadb;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartMariadb{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneMariadb $database;@@ -20,7 +22,7 @@ class StartMariadbprivate ?SslCertificate $ssl_certificate = null;- public function handle(StandaloneMariadb $database)+ public function handle(StandaloneMariadb $database, ?Activity $activity = null){$this->database = $database;@@ -216,7 +218,7 @@ class StartMariadb$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.phpindex ef344f1d32..f6ea641b4b 100644--- a/app/Actions/Database/StartMongodb.php+++ b/app/Actions/Database/StartMongodb.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandaloneMongodb;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartMongodb{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneMongodb $database;@@ -26,7 +28,7 @@ class StartMongodbprivate string $resolvedMongoDatabase;- public function handle(StandaloneMongodb $database)+ public function handle(StandaloneMongodb $database, ?Activity $activity = null){$this->database = $database;@@ -271,7 +273,7 @@ class StartMongodb$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.phpindex da1ccab6dd..0615f15ca9 100644--- a/app/Actions/Database/StartMysql.php+++ b/app/Actions/Database/StartMysql.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandaloneMysql;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartMysql{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneMysql $database;@@ -22,7 +24,7 @@ class StartMysqlprivate string $resolvedMysqlRootPassword;- public function handle(StandaloneMysql $database)+ public function handle(StandaloneMysql $database, ?Activity $activity = null){$this->database = $database;@@ -220,7 +222,7 @@ class StartMysql$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpindex 5071e5b868..6e62b29707 100644--- a/app/Actions/Database/StartPostgresql.php+++ b/app/Actions/Database/StartPostgresql.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandalonePostgresql;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartPostgresql{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandalonePostgresql $database;@@ -26,7 +28,7 @@ class StartPostgresqlprivate string $resolvedPostgresDatabase;- public function handle(StandalonePostgresql $database)+ public function handle(StandalonePostgresql $database, ?Activity $activity = null){$this->database = $database;$container_name = $this->database->uuid;@@ -231,7 +233,7 @@ class StartPostgresql$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.phpindex b44baa2e87..41ece532b1 100644--- a/app/Actions/Database/StartRedis.php+++ b/app/Actions/Database/StartRedis.php@@ -5,12 +5,14 @@ namespace App\Actions\Database;use App\Helpers\SslHelper;use App\Models\SslCertificate;use App\Models\StandaloneRedis;+use App\Traits\ExecutesDatabaseStartCommands;use Lorisleiva\Actions\Concerns\AsAction;+use Spatie\Activitylog\Models\Activity;use Symfony\Component\Yaml\Yaml;class StartRedis{- use AsAction;+ use AsAction, ExecutesDatabaseStartCommands;public StandaloneRedis $database;@@ -24,7 +26,7 @@ class StartRedisprivate ?string $resolvedRedisUsername = null;- public function handle(StandaloneRedis $database)+ public function handle(StandaloneRedis $database, ?Activity $activity = null){$this->database = $database;@@ -213,7 +215,7 @@ class StartRedis$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo 'Database started.'";- return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ return $this->executeDatabaseStartCommands($this->commands, $database, $activity);}private function generate_local_persistent_volumes()diff --git a/app/Jobs/DatabaseStartJob.php b/app/Jobs/DatabaseStartJob.phpnew file mode 100644index 0000000000..da93a2dd21--- /dev/null+++ b/app/Jobs/DatabaseStartJob.php@@ -0,0 +1,85 @@+<?php++namespace App\Jobs;++use App\Actions\Database\StartClickhouse;+use App\Actions\Database\StartDragonfly;+use App\Actions\Database\StartKeydb;+use App\Actions\Database\StartMariadb;+use App\Actions\Database\StartMongodb;+use App\Actions\Database\StartMysql;+use App\Actions\Database\StartPostgresql;+use App\Actions\Database\StartRedis;+use App\Enums\ProcessStatus;+use App\Events\DatabaseStatusChanged;+use App\Models\StandaloneClickhouse;+use App\Models\StandaloneDragonfly;+use App\Models\StandaloneKeydb;+use App\Models\StandaloneMariadb;+use App\Models\StandaloneMongodb;+use App\Models\StandaloneMysql;+use App\Models\StandalonePostgresql;+use App\Models\StandaloneRedis;+use Illuminate\Bus\Queueable;+use Illuminate\Contracts\Queue\ShouldBeEncrypted;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Foundation\Bus\Dispatchable;+use Illuminate\Queue\InteractsWithQueue;+use Illuminate\Queue\SerializesModels;+use Spatie\Activitylog\Models\Activity;+use Throwable;++class DatabaseStartJob implements ShouldBeEncrypted, ShouldQueue+{+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;++ public int $tries = 1;++ public int $timeout = 600;++ public function __construct(+ public string $databaseClass,+ public int $databaseId,+ public int $teamId,+ public int $activityId,+ ) {+ $this->onQueue(deployment_queue());+ }++ public function handle(): void+ {+ $database = $this->databaseClass::query()->findOrFail($this->databaseId);+ abort_unless((int) $database->team()->id === $this->teamId, 403);+ $activity = Activity::query()->findOrFail($this->activityId);++ try {+ match ($database->getMorphClass()) {+ StandalonePostgresql::class => StartPostgresql::run($database, $activity),+ StandaloneRedis::class => StartRedis::run($database, $activity),+ StandaloneMongodb::class => StartMongodb::run($database, $activity),+ StandaloneMysql::class => StartMysql::run($database, $activity),+ StandaloneMariadb::class => StartMariadb::run($database, $activity),+ StandaloneKeydb::class => StartKeydb::run($database, $activity),+ StandaloneDragonfly::class => StartDragonfly::run($database, $activity),+ StandaloneClickhouse::class => StartClickhouse::run($database, $activity),+ };+ } finally {+ event(new DatabaseStatusChanged($database));+ }+ }++ public function failed(?Throwable $exception): void+ {+ $activity = Activity::query()->find($this->activityId);+ if (! $activity) {+ return;+ }++ $activity->properties = $activity->properties->merge([+ 'status' => ProcessStatus::ERROR->value,+ 'error' => 'Database start failed.',+ 'failed_at' => now()->toIso8601String(),+ ]);+ $activity->save();+ }+}diff --git a/app/Services/DatabaseStartCommandExecutor.php b/app/Services/DatabaseStartCommandExecutor.phpnew file mode 100644index 0000000000..dab3599101--- /dev/null+++ b/app/Services/DatabaseStartCommandExecutor.php@@ -0,0 +1,77 @@+<?php++namespace App\Services;++use App\Enums\ProcessStatus;+use App\Helpers\SshMultiplexingHelper;+use Illuminate\Database\Eloquent\Model;+use Illuminate\Support\Facades\Process;+use Spatie\Activitylog\Models\Activity;++class DatabaseStartCommandExecutor+{+ public function execute(array $commands, Model $database, Activity $activity): Activity+ {+ $server = $database->destination->server;+ if ($server->isNonRoot()) {+ $commands = parseCommandsByLineForSudo(collect($commands), $server)->all();+ }++ $secrets = method_exists($database, 'resolvedSecretManagerValuesForRedaction')+ ? $database->resolvedSecretManagerValuesForRedaction()+ : [];+ $remoteCommand = SshMultiplexingHelper::generateSshCommand($server, implode("\n", $commands));++ $activity->properties = $activity->properties->merge(['status' => ProcessStatus::IN_PROGRESS->value]);+ $activity->save();++ $process = Process::timeout(config('constants.ssh.command_timeout'))+ ->idleTimeout(3600)+ ->start($remoteCommand, function (string $type, string $output) use ($activity, $secrets): void {+ $this->appendOutput($activity, $type, $this->redact($output, $secrets));+ });++ $result = $process->wait();+ $status = $result->successful() ? ProcessStatus::FINISHED : ProcessStatus::ERROR;+ $activity->properties = $activity->properties->merge([+ 'status' => $status->value,+ 'exitCode' => $result->exitCode(),+ ]);+ $activity->save();++ if (! $result->successful()) {+ throw new \RuntimeException($this->redact($result->errorOutput(), $secrets), $result->exitCode());+ }++ return $activity;+ }++ private function redact(string $value, array $secrets): string+ {+ foreach ($secrets as $secret) {+ if (is_string($secret) && $secret !== '') {+ $value = str_replace($secret, REDACTED, $value);+ }+ }++ return sanitize_utf8_text(remove_iip($value));+ }++ private function appendOutput(Activity $activity, string $type, string $output): void+ {+ if ($output === '') {+ return;+ }++ $entries = json_decode($activity->description ?: '[]', true, flags: JSON_THROW_ON_ERROR);+ $entries[] = [+ 'type' => $type,+ 'output' => $output,+ 'timestamp' => hrtime(true),+ 'batch' => 1,+ 'order' => count($entries) + 1,+ ];+ $activity->description = json_encode($entries, flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);+ $activity->save();+ }+}diff --git a/app/Traits/ExecutesDatabaseStartCommands.php b/app/Traits/ExecutesDatabaseStartCommands.phpnew file mode 100644index 0000000000..d267a8b1b2--- /dev/null+++ b/app/Traits/ExecutesDatabaseStartCommands.php@@ -0,0 +1,19 @@+<?php++namespace App\Traits;++use App\Services\DatabaseStartCommandExecutor;+use Illuminate\Database\Eloquent\Model;+use Spatie\Activitylog\Models\Activity;++trait ExecutesDatabaseStartCommands+{+ private function executeDatabaseStartCommands(array $commands, Model $database, ?Activity $activity = null): Activity+ {+ if ($activity) {+ return app(DatabaseStartCommandExecutor::class)->execute($commands, $database, $activity);+ }++ return remote_process($commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');+ }+}diff --git a/app/Traits/HasSecretManager.php b/app/Traits/HasSecretManager.phpindex 01bc98cd73..7ade50e4ba 100644--- a/app/Traits/HasSecretManager.php+++ b/app/Traits/HasSecretManager.php@@ -93,4 +93,10 @@ trait HasSecretManagerreturn $this->resolvedSecretManagerValues = $link->fetchSecrets();}++ /** @return array<string, string> */+ public function resolvedSecretManagerValuesForRedaction(): array+ {+ return $this->resolvedSecretManagerValues ?? [];+ }}diff --git a/resources/views/livewire/project/database/configuration.blade.php b/resources/views/livewire/project/database/configuration.blade.phpindex f24f6b648a..5f7f4c5797 100644--- a/resources/views/livewire/project/database/configuration.blade.php+++ b/resources/views/livewire/project/database/configuration.blade.php@@ -30,8 +30,8 @@<livewire:project.database.clickhouse.general :database="$database" />@endif@elseif ($currentRoute === 'project.database.environment-variables')- <livewire:project.shared.secret-manager-links :resource="$database" /><livewire:project.shared.environment-variable.all :resource="$database" />+ <livewire:project.shared.secret-manager-links :resource="$database" />@elseif ($currentRoute === 'project.database.servers')<livewire:project.shared.destination :resource="$database" />@elseif ($currentRoute === 'project.database.persistent-storage')diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.phpindex 2fb4aee014..02855fec27 100644--- a/resources/views/livewire/project/service/configuration.blade.php+++ b/resources/views/livewire/project/service/configuration.blade.php@@ -178,8 +178,8 @@@elseif ($currentRoute === 'project.service.domains')<livewire:project.service.domains :service="$service" />@elseif ($currentRoute === 'project.service.environment-variables')- <livewire:project.shared.secret-manager-links :resource="$service" /><livewire:project.shared.environment-variable.all :resource="$service" />+ <livewire:project.shared.secret-manager-links :resource="$service" />@elseif ($currentRoute === 'project.service.storages')<div class="space-y-6"><divdiff --git a/tests/Unit/DatabaseStartActionResolvedCredentialsTest.php b/tests/Unit/DatabaseStartActionResolvedCredentialsTest.phpindex fc63a41eb4..364d544904 100644--- a/tests/Unit/DatabaseStartActionResolvedCredentialsTest.php+++ b/tests/Unit/DatabaseStartActionResolvedCredentialsTest.php@@ -37,3 +37,30 @@ it('reuses resolved environment credentials in database startup integrations', f['$this->database->postgres_user, \'-d\'', '$this->database->postgres_db, \'-c\''],],]);++it('runs database start commands without persisting them through remote process', function (string $action) {+ $source = file_get_contents(__DIR__."/../../app/Actions/Database/{$action}.php");++ expect($source)+ ->toContain('ExecutesDatabaseStartCommands')+ ->toContain('executeDatabaseStartCommands(')+ ->not->toContain('return remote_process(');+})->with([+ 'StartClickhouse',+ 'StartDragonfly',+ 'StartKeydb',+ 'StartMariadb',+ 'StartMongodb',+ 'StartMysql',+ 'StartPostgresql',+ 'StartRedis',+]);++it('queues database starts with identifiers instead of generated commands', function () {+ $source = file_get_contents(__DIR__.'/../../app/Actions/Database/StartDatabase.php');++ expect($source)+ ->toContain('DatabaseStartJob::dispatch(')+ ->not->toContain('StartPostgresql::run(')+ ->not->toContain('StartRedis::run(');+});diff --git a/tests/Unit/SecretManagerLayoutConsistencyTest.php b/tests/Unit/SecretManagerLayoutConsistencyTest.phpnew file mode 100644index 0000000000..82d7f82c34--- /dev/null+++ b/tests/Unit/SecretManagerLayoutConsistencyTest.php@@ -0,0 +1,15 @@+<?php++it('shows environment variables before the optional secret manager for every resource type', function (string $view, string $resource) {+ $source = file_get_contents(__DIR__."/../../resources/views/livewire/project/{$view}/configuration.blade.php");+ $environmentVariables = '<livewire:project.shared.environment-variable.all :resource="$'.$resource.'" />';+ $secretManager = '<livewire:project.shared.secret-manager-links :resource="$'.$resource.'" />';++ expect($source)+ ->toContain($environmentVariables, $secretManager)+ ->and(strpos($source, $environmentVariables))->toBeLessThan(strpos($source, $secretManager));+})->with([+ 'application' => ['application', 'application'],+ 'database' => ['database', 'database'],+ 'service' => ['service', 'service'],+]);