mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-14 00:33:44 -04:00
fix(settings): keep manually set instance public IPs on restart
Closes #11802 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
97f451cc2a
commit
70d4dad494
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use App\Models\InstanceSettings;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Process::fake([
|
||||
'curl -4s https://ifconfig.io' => "203.0.113.1\n",
|
||||
'curl -6s https://ifconfig.io' => "2001:db8::1\n",
|
||||
]);
|
||||
});
|
||||
|
||||
it('detects the public IPs when the settings are empty', function () {
|
||||
InstanceSettings::forceCreate(['id' => 0]);
|
||||
|
||||
get_public_ips();
|
||||
|
||||
$settings = InstanceSettings::find(0);
|
||||
expect($settings->public_ipv4)->toBe('203.0.113.1')
|
||||
->and($settings->public_ipv6)->toBe('2001:db8::1');
|
||||
});
|
||||
|
||||
it('keeps public IPs that are already set', function () {
|
||||
InstanceSettings::forceCreate(['id' => 0, 'public_ipv4' => '203.0.113.21', 'public_ipv6' => '2001:db8::21']);
|
||||
|
||||
get_public_ips();
|
||||
|
||||
$settings = InstanceSettings::find(0);
|
||||
expect($settings->public_ipv4)->toBe('203.0.113.21')
|
||||
->and($settings->public_ipv6)->toBe('2001:db8::21');
|
||||
Process::assertNothingRan();
|
||||
});
|
||||
|
||||
it('detects only the address family that is empty', function () {
|
||||
InstanceSettings::forceCreate(['id' => 0, 'public_ipv4' => '203.0.113.21']);
|
||||
|
||||
get_public_ips();
|
||||
|
||||
$settings = InstanceSettings::find(0);
|
||||
expect($settings->public_ipv4)->toBe('203.0.113.21')
|
||||
->and($settings->public_ipv6)->toBe('2001:db8::1');
|
||||
Process::assertNotRan('curl -4s https://ifconfig.io');
|
||||
});
|
||||
|
||||
it('still detects IPv6 when the IPv4 lookup returns an invalid address', function () {
|
||||
Process::fake([
|
||||
'curl -4s https://ifconfig.io' => 'not-an-ip',
|
||||
'curl -6s https://ifconfig.io' => "2001:db8::1\n",
|
||||
]);
|
||||
InstanceSettings::forceCreate(['id' => 0]);
|
||||
|
||||
get_public_ips();
|
||||
|
||||
$settings = InstanceSettings::find(0);
|
||||
expect($settings->public_ipv4)->toBeNull()
|
||||
->and($settings->public_ipv6)->toBe('2001:db8::1');
|
||||
});
|
||||
Reference in New Issue
Block a user