Files
coolify/tests/Unit/InstallScriptAuthorizedKeysTest.php
T
peaklabs-dev e0fb2b3897 ci(release): build and release a nightly twice a day
- Remove other/nightly, the nightly channel uses the production files, so there are no longer two copies to keep in sync
- sync-cdn.sh --nightly syncs the files of the commit the nightly is built from to /coolify/nightly on the CDN, with the nightly version in its versions.json and in /coolify/release.json, and pushes them straight to main of coollabs-cdn
- version.sh picks the branch the nightly comes from, the release branch of the next version after the newest stable one or next, and names the version <preview>.<YYYYMMDD>.<N>
- The image is labeled with its version and commit, the nightly workflow reads both from the image nightly points at to count up N and to skip a run without a new commit
2026-11-01 19:37:39 +01:00

42 lines
2.0 KiB
PHP

<?php
use Symfony\Component\Process\Process;
it('removes only previous Coolify keys from authorized_keys', function (string $path) {
$script = file_get_contents(dirname(__DIR__, 2).'/'.$path);
preg_match('/^\s*(sed -i .*~\/\.ssh\/authorized_keys)$/m', $script, $matches);
expect($matches)->toHaveKey(1);
$home = sys_get_temp_dir().'/coolify-install-keys-'.bin2hex(random_bytes(4));
mkdir($home.'/.ssh', 0700, true);
file_put_contents($home.'/.ssh/authorized_keys', implode("\n", [
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-disposable',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey operator-lab',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey me@coolify-laptop',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-ops key',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey admin@root@coolify.example.com',
'no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOptions deploy@coolify.example.com',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOldCoolifyKey coolify',
// Installers before September 2024 generated their key with the comment "root@coolify".
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOlderCoolifyKey root@coolify',
'',
]));
$process = new Process(['bash', '-c', $matches[1]], null, ['HOME' => $home]);
$process->mustRun();
expect(file_get_contents($home.'/.ssh/authorized_keys'))->toBe(implode("\n", [
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-disposable',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey operator-lab',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey me@coolify-laptop',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey coolify-ops key',
'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOperatorKey admin@root@coolify.example.com',
'no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOptions deploy@coolify.example.com',
'',
]));
exec('rm -rf '.escapeshellarg($home));
})->with([
'stable install script' => ['scripts/install.sh'],
]);