Files
coolify/tests/Feature/Proxy/RuntimeNetworkReconciliationTest.php
Andras Bacsai 0d23b29775 fix: honor GitHub default branches and reconcile proxy networks
Use searchable repository and branch selectors, select each repository's default branch when available, and discover running container networks during proxy reconciliation.
2026-08-18 09:16:29 +02:00

54 lines
1.8 KiB
PHP

<?php
use App\Models\Server;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('discovers running container networks instead of relying on cached resource statuses', function () {
$team = Team::factory()->create();
$server = Server::factory()->create(['team_id' => $team->id]);
$commands = connectProxyToNetworks($server)->implode("\n");
expect($commands)
->toContain('docker ps --filter label=coolify.managed=true')
->toContain('.NetworkSettings.Networks')
->toContain('docker network inspect "$network"')
->toContain('docker network connect "$network" coolify-proxy')
->not->toContain('docker network create');
});
it('skips Docker system networks during runtime reconciliation', function () {
$team = Team::factory()->create();
$server = Server::factory()->create(['team_id' => $team->id]);
$commands = connectProxyToNetworks($server)->implode("\n");
expect($commands)
->toContain('"$network" = "bridge"')
->toContain('"$network" = "host"')
->toContain('"$network" = "none"')
->toContain('"$network" = "default"');
});
it('preserves runtime reconciliation loops for non-root SSH users', function () {
$team = Team::factory()->create();
$server = Server::factory()->create([
'team_id' => $team->id,
'user' => 'ubuntu',
]);
$commands = collect(parseCommandsByLineForSudo(connectProxyToNetworks($server), $server))->implode("\n");
expect($commands)
->toContain('$(sudo docker ps')
->toMatch('/sudo\s+docker inspect/')
->toMatch('/sudo\s+docker network inspect/')
->toMatch('/sudo\s+docker network connect/')
->not->toContain('sudo while')
->not->toContain('sudo done')
->not->toContain('sudo continue');
});