mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-08 22:24:37 +00:00
feat(server): add configurable SSH connection timeout per server
Add `connection_timeout` field to server settings, allowing per-server override of the global SSH connection timeout constant. - Migration adds `connection_timeout` integer column (default 10s) - `ServerSetting` model exposes and casts the new field - `SshMultiplexingHelper::getConnectionTimeout()` resolves per-server value with fallback to `constants.ssh.connection_timeout` - All SSH/SCP command builders use the new resolver instead of the global config directly - Livewire `Show` component binds `connectionTimeout` with validation (1–300 seconds) and syncs to/from the model - UI input added to server settings form with helper text - Feature tests cover default, persistence, resolver, and fallback
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SshMultiplexingHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$user = User::factory()->create();
|
||||
$this->team = $user->teams()->first();
|
||||
$this->server = Server::factory()->create([
|
||||
'team_id' => $this->team->id,
|
||||
]);
|
||||
});
|
||||
|
||||
it('defaults connection_timeout to 10 seconds for new servers', function () {
|
||||
expect($this->server->settings->connection_timeout)->toBe(10);
|
||||
});
|
||||
|
||||
it('persists a custom connection_timeout value', function () {
|
||||
$this->server->settings->connection_timeout = 30;
|
||||
$this->server->settings->save();
|
||||
|
||||
expect($this->server->settings->fresh()->connection_timeout)->toBe(30);
|
||||
});
|
||||
|
||||
it('returns the per-server connection_timeout from getConnectionTimeout', function () {
|
||||
$this->server->settings->connection_timeout = 45;
|
||||
$this->server->settings->save();
|
||||
|
||||
expect(SshMultiplexingHelper::getConnectionTimeout($this->server->fresh()))->toBe(45);
|
||||
});
|
||||
|
||||
it('falls back to config default when connection_timeout is invalid', function () {
|
||||
$this->server->settings->connection_timeout = 0;
|
||||
$this->server->settings->saveQuietly();
|
||||
|
||||
$expected = (int) config('constants.ssh.connection_timeout');
|
||||
|
||||
expect(SshMultiplexingHelper::getConnectionTimeout($this->server->fresh()))->toBe($expected);
|
||||
});
|
||||
Reference in New Issue
Block a user