mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-08 06:56:02 -04:00
The mkdir ownership rule prepended `sudo` to chown/chmod, and the && rule then added another, producing `sudo sudo`. That fails on hosts like Alpine, where root is not in sudoers. Both parseCommandsByLineForSudo and parseLineForSudo now leave the prefix to the && rule. Also: - Fix the `App\Helpers\SSLHelper` reference in RegenerateSslCertJob to `SslHelper`, so it autoloads on case-sensitive filesystems. - Stop StartPostgresql and StartMongodb from overriding the configuration dir with a hardcoded Docker volume path in development. - Add tests for nested sudo behaviour, the class reference letter case and database configuration dirs in development.
66 lines
2.6 KiB
PHP
66 lines
2.6 KiB
PHP
<?php
|
|
|
|
use App\Actions\Database\StartMongodb;
|
|
use App\Actions\Database\StartPostgresql;
|
|
use App\Models\Environment;
|
|
use App\Models\InstanceSettings;
|
|
use App\Models\PrivateKey;
|
|
use App\Models\Project;
|
|
use App\Models\Server;
|
|
use App\Models\StandaloneDocker;
|
|
use App\Models\Team;
|
|
use App\Services\DatabaseStartCommandExecutor;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Process;
|
|
use Illuminate\Support\Facades\Queue;
|
|
use Spatie\Activitylog\Models\Activity;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
InstanceSettings::forceCreate(['id' => 0]);
|
|
config(['app.env' => 'local', 'app.maintenance.store' => 'array', 'cache.default' => 'array']);
|
|
Process::fake();
|
|
Queue::fake();
|
|
|
|
$team = Team::factory()->create();
|
|
$privateKey = PrivateKey::factory()->create(['team_id' => $team->id]);
|
|
$server = Server::factory()->create(['team_id' => $team->id, 'private_key_id' => $privateKey->id]);
|
|
$this->destination = StandaloneDocker::query()->where('server_id', $server->id)->firstOrFail();
|
|
$project = Project::factory()->create(['team_id' => $team->id]);
|
|
$this->environment = Environment::factory()->create(['project_id' => $project->id]);
|
|
|
|
$this->executor = new class
|
|
{
|
|
public array $commands = [];
|
|
|
|
public function execute(array $commands, $database, Activity $activity): Activity
|
|
{
|
|
$this->commands = $commands;
|
|
|
|
return $activity;
|
|
}
|
|
};
|
|
app()->instance(DatabaseStartCommandExecutor::class, $this->executor);
|
|
});
|
|
|
|
test('databases with SSL use their normal configuration folder in development', function (string $type) {
|
|
$database = $type === 'postgresql'
|
|
? create_standalone_postgresql($this->environment->id, $this->destination)
|
|
: create_standalone_mongodb($this->environment->id, $this->destination);
|
|
$database->update(['enable_ssl' => true]);
|
|
|
|
($type === 'postgresql' ? StartPostgresql::class : StartMongodb::class)::run($database->fresh(), new Activity);
|
|
|
|
$certificateFiles = $database->fileStorages()->pluck('fs_path');
|
|
|
|
expect(isDev())->toBeTrue()
|
|
->and(implode("\n", $this->executor->commands))
|
|
->toContain('mkdir -p '.$database->workdir())
|
|
->not->toContain('coolify_dev_coolify_data')
|
|
->and($certificateFiles)->not->toBeEmpty()
|
|
->each->toStartWith($database->workdir().'/ssl/');
|
|
// The file-mount path check accepts every certificate file.
|
|
$certificateFiles->each(fn (string $path) => confinePathToBase($database->workdir(), $path, 'storage path'));
|
|
})->with(['postgresql', 'mongodb']);
|