Files
coolify/tests/Feature/ServerConnectionChangeClosesMuxTest.php
Andras Bacsai 0e3b6e5aa6 fix(databases): apply custom configs on servers with a strict umask
A custom config file written with tee gets the server umask. With umask
027 or 077 the file is not readable by the container user, so MySQL and
MariaDB ignored the whole config without an error.

- Set mode 644 on the MySQL, MariaDB, PostgreSQL, and MongoDB custom
  config files after each write.
- Close the multiplexed SSH connection when the server user, IP, or port
  changes, so the next command does not run as the old user.

Closes #11600
2026-10-16 21:28:21 +02:00

41 lines
1.3 KiB
PHP

<?php
use App\Models\InstanceSettings;
use App\Models\PrivateKey;
use App\Models\Server;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Process;
uses(RefreshDatabase::class);
beforeEach(function () {
Server::flushIdentityMap();
InstanceSettings::forceCreate(['id' => 0]);
$team = Team::factory()->create();
$privateKey = PrivateKey::factory()->create(['team_id' => $team->id]);
$this->server = Server::factory()->create(['team_id' => $team->id, 'private_key_id' => $privateKey->id, 'user' => 'root']);
Process::fake();
});
function closesServerMux(Server $server): Closure
{
return fn ($process) => str_contains($process->command, 'ssh -O stop') && str_contains($process->command, "mux_{$server->uuid}");
}
it('closes the multiplexed SSH connection when the connection details change', function (array $changes) {
$this->server->update($changes);
Process::assertRan(closesServerMux($this->server));
})->with([
'user' => [['user' => 'deploy']],
'ip' => [['ip' => '203.0.113.20']],
'port' => [['port' => 2222]],
]);
it('keeps the multiplexed SSH connection when other server fields change', function () {
$this->server->update(['name' => 'renamed', 'description' => 'changed']);
Process::assertDidntRun(closesServerMux($this->server));
});