diff --git a/app/Jobs/ValidateAndInstallServerJob.php b/app/Jobs/ValidateAndInstallServerJob.php index 7ebfbbc142..c6e8f53957 100644 --- a/app/Jobs/ValidateAndInstallServerJob.php +++ b/app/Jobs/ValidateAndInstallServerJob.php @@ -180,7 +180,7 @@ class ValidateAndInstallServerJob implements ShouldBeEncrypted, ShouldQueue ]); // Start proxy if needed - if (! $this->server->isBuildServer()) { + if ($this->server->isProxyShouldRun()) { $proxyShouldRun = CheckProxy::run($this->server, true); if ($proxyShouldRun) { // Ensure networks exist BEFORE dispatching async proxy startup diff --git a/app/Livewire/Server/ValidateAndInstall.php b/app/Livewire/Server/ValidateAndInstall.php index c7ce754732..84b2ffaa32 100644 --- a/app/Livewire/Server/ValidateAndInstall.php +++ b/app/Livewire/Server/ValidateAndInstall.php @@ -310,6 +310,11 @@ class ValidateAndInstall extends Component if ($this->server->isSentinelEnabled()) { CheckAndStartSentinelJob::dispatch($this->server); } + if (! $this->server->isProxyShouldRun()) { + $this->dispatch('success', 'Server validated.'); + + return; + } $this->dispatch('success', 'Server validated, proxy is starting in a moment.'); $proxyShouldRun = CheckProxy::run($this->server, true); if (! $proxyShouldRun) { diff --git a/tests/Feature/ServerDockerVersionValidationTest.php b/tests/Feature/ServerDockerVersionValidationTest.php index f41992431c..b7fd74ef29 100644 --- a/tests/Feature/ServerDockerVersionValidationTest.php +++ b/tests/Feature/ServerDockerVersionValidationTest.php @@ -1,6 +1,9 @@ server->fresh())) ->toContain('Run "sudo docker version --format json" on the server as the deploy user'); }); + +it('validates a server without a proxy and does not start a proxy', function () { + Queue::fake(); + $this->server->proxy->set('type', ProxyTypes::NONE->value); + $this->server->save(); + $this->server->settings->update(['is_reachable' => true, 'is_usable' => true]); + fakeDockerVersionOutput('{"Server":{"Version":"29.6.2"}}'); + + expect(validateDockerVersionError($this->server->fresh()))->toBeNull() + ->and($this->server->fresh()->is_validating)->toBeFalsy(); + Queue::assertNotPushed(StartProxy::class); +}); + +it('validates a server without a proxy in the background job', function () { + Queue::fake(); + $this->server->proxy->set('type', ProxyTypes::NONE->value); + $this->server->save(); + $this->server->settings->update(['is_reachable' => true, 'is_usable' => true]); + + $server = Mockery::mock($this->server->fresh())->makePartial(); + $server->shouldReceive('validateConnection')->andReturn(['uptime' => true, 'error' => null]); + $server->shouldReceive('validateOS')->andReturn('debian'); + $server->shouldReceive('validatePrerequisites')->andReturn(['success' => true]); + $server->shouldReceive('validateDockerEngine')->andReturn(true); + $server->shouldReceive('validateDockerCompose')->andReturn(true); + $server->shouldReceive('validateDockerEngineVersion')->andReturn(true); + $server->shouldReceive('gatherServerMetadata')->andReturnNull(); + + (new ValidateAndInstallServerJob($server))->handle(); + + expect($this->server->fresh()->validation_logs)->toBeNull() + ->and($this->server->fresh()->is_validating)->toBeFalsy(); + Queue::assertNotPushed(StartProxy::class); +});