Expand VS Code generated SSH config paths
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
|
||||
const {
|
||||
expandHomePath,
|
||||
ensureInclude,
|
||||
shellQuote,
|
||||
sshBlock,
|
||||
sshConfigPathWord,
|
||||
sshIncludeTarget,
|
||||
sshConfigWord,
|
||||
upsertBlock,
|
||||
windowsCommandWord
|
||||
} = require('./extension');
|
||||
|
||||
@@ -83,3 +89,35 @@ test('ssh include target handles Windows custom generated config paths', () => {
|
||||
'C:/Users/palav/.ssh/config.dosh'
|
||||
);
|
||||
});
|
||||
|
||||
test('home-relative generated config paths expand for POSIX and Windows', () => {
|
||||
assert.equal(
|
||||
expandHomePath('~/Library/Application Support/Dosh/config.dosh', '/Users/palav', 'darwin'),
|
||||
'/Users/palav/Library/Application Support/Dosh/config.dosh'
|
||||
);
|
||||
assert.equal(
|
||||
expandHomePath('~\\.ssh\\config.dosh', 'C:\\Users\\palav', 'win32'),
|
||||
'C:\\Users\\palav\\.ssh\\config.dosh'
|
||||
);
|
||||
});
|
||||
|
||||
test('config writers create missing parent directories', () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'dosh-vscode-'));
|
||||
const mainConfig = path.join(root, 'ssh', 'config');
|
||||
const generatedConfig = path.join(root, 'generated', 'config.dosh');
|
||||
|
||||
ensureInclude(mainConfig, '../generated/config.dosh');
|
||||
upsertBlock(
|
||||
generatedConfig,
|
||||
'dosh-test',
|
||||
[
|
||||
'# BEGIN DOSH dosh-test',
|
||||
'Host dosh-test',
|
||||
' ProxyCommand dosh proxy-stdio test %h %p',
|
||||
'# END DOSH dosh-test'
|
||||
].join('\n')
|
||||
);
|
||||
|
||||
assert.equal(fs.readFileSync(mainConfig, 'utf8'), 'Include ../generated/config.dosh\n');
|
||||
assert.match(fs.readFileSync(generatedConfig, 'utf8'), /Host dosh-test/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user