mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 16:14:35 +00:00
fix(git-import): ensure ssh key is used for fetch, submodule, and lfs operations (#8933)
This commit is contained in:
2 files changed
+73
-9
No files matched your search
@@ -85,4 +85,62 @@ describe('Application Rollback', function () {
|
||||
|
||||
expect($result)->not->toContain('advice.detachedHead=false checkout');
|
||||
});
|
||||
|
||||
test('setGitImportSettings uses provided git_ssh_command for fetch', function () {
|
||||
$this->application->settings->is_git_shallow_clone_enabled = true;
|
||||
$rollbackCommit = 'abc123def456abc123def456abc123def456abc1';
|
||||
$sshCommand = 'GIT_SSH_COMMAND="ssh -o ConnectTimeout=30 -p 22222 -o Port=22222 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa"';
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
git_clone_command: 'git clone',
|
||||
commit: $rollbackCommit,
|
||||
git_ssh_command: $sshCommand,
|
||||
);
|
||||
|
||||
expect($result)
|
||||
->toContain('-i /root/.ssh/id_rsa" git fetch --depth=1 origin')
|
||||
->toContain($rollbackCommit);
|
||||
});
|
||||
|
||||
test('setGitImportSettings uses provided git_ssh_command for submodule update', function () {
|
||||
$this->application->settings->is_git_submodules_enabled = true;
|
||||
$sshCommand = 'GIT_SSH_COMMAND="ssh -o ConnectTimeout=30 -p 22 -o Port=22 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa"';
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
git_clone_command: 'git clone',
|
||||
git_ssh_command: $sshCommand,
|
||||
);
|
||||
|
||||
expect($result)
|
||||
->toContain('-i /root/.ssh/id_rsa" git submodule update --init --recursive');
|
||||
});
|
||||
|
||||
test('setGitImportSettings uses provided git_ssh_command for lfs pull', function () {
|
||||
$this->application->settings->is_git_lfs_enabled = true;
|
||||
$sshCommand = 'GIT_SSH_COMMAND="ssh -o ConnectTimeout=30 -p 22 -o Port=22 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa"';
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
git_clone_command: 'git clone',
|
||||
git_ssh_command: $sshCommand,
|
||||
);
|
||||
|
||||
expect($result)->toContain('-i /root/.ssh/id_rsa" git lfs pull');
|
||||
});
|
||||
|
||||
test('setGitImportSettings uses default ssh command when git_ssh_command not provided', function () {
|
||||
$this->application->settings->is_git_lfs_enabled = true;
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
git_clone_command: 'git clone',
|
||||
public: true,
|
||||
);
|
||||
|
||||
expect($result)
|
||||
->toContain('GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git lfs pull')
|
||||
->not->toContain('-i /root/.ssh/id_rsa');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user