Files
coolify/tests/Feature/PublicGitRepositorySshUrlTest.php
Andras BacsaiandClaude Opus 5.5 7466da12a2 fix(git): accept ssh:// repository URLs with custom ports
The repository URL rule rejected ssh://user@host:port/path, so deploy-key
resources on servers with a custom SSH port needed a manual URL edit after
creation. Accept ssh:// URLs and keep them unchanged for deploy keys so the
port reaches the clone. Rename scpStyleGitUrlToHttps to sshGitUrlToHttps and
let it convert ssh:// URLs too, so public flows, repository links and GitHub
App repository slugs handle them.

Closes #12161

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 22:30:26 +02:00

43 lines
1.6 KiB
PHP

<?php
use App\Livewire\Project\New\PublicGitRepository;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
$team = Team::factory()->create();
$user = User::factory()->create();
$team->members()->attach($user->id, ['role' => 'owner']);
$this->actingAs($user);
session(['currentTeam' => $team]);
});
test('converts scp-style ssh urls with custom usernames to https', function () {
Livewire::test(PublicGitRepository::class, ['type' => 'public'])
->set('repository_url', 'custom-user@git.example.com:organization/repository.git')
->call('loadBranch')
->assertSet('repository_url', 'https://git.example.com/organization/repository.git')
->assertSet('branchFound', true);
});
test('strips custom ports when converting scp-style ssh urls to https', function () {
Livewire::test(PublicGitRepository::class, ['type' => 'public'])
->set('repository_url', 'custom-user@git.example.com:2222/organization/repository.git')
->call('loadBranch')
->assertSet('repository_url', 'https://git.example.com/organization/repository.git')
->assertSet('branchFound', true);
});
test('converts ssh scheme urls with custom ports to https', function () {
Livewire::test(PublicGitRepository::class, ['type' => 'public'])
->set('repository_url', 'ssh://git@gitea.example.com:2222/organization/repository.git')
->call('loadBranch')
->assertSet('repository_url', 'https://gitea.example.com/organization/repository.git')
->assertSet('branchFound', true);
});