Support OpenSSH Include expansion for SSH config imports

Closes #2647
This commit is contained in:
Phil Denhoff
2026-05-23 00:27:20 -07:00
committed by GitHub
parent 59ac13dc53
commit 2dcaa78960
6 changed files with 961 additions and 34 deletions
@@ -0,0 +1,39 @@
import { describe, expect, it } from 'vitest'
import { parseSshConfig } from './ssh-config-parser'
describe('parseSshConfig host pattern filtering', () => {
it('ignores negated aliases on mixed Host lines', () => {
const config = `
Host prod !prod-admin
HostName prod.example.com
`
expect(parseSshConfig(config)).toEqual([{ host: 'prod', hostname: 'prod.example.com' }])
})
it('imports only literal positive aliases from mixed wildcard and negated patterns', () => {
const config = `
Host !legacy *.corp prod
HostName prod.example.com
`
expect(parseSshConfig(config)).toEqual([{ host: 'prod', hostname: 'prod.example.com' }])
})
it('ignores inline comments on mixed Host lines', () => {
const config = `
Host prod stage # shared production aliases
HostName prod.example.com
`
expect(parseSshConfig(config)).toEqual([
{ host: 'prod', hostname: 'prod.example.com' },
{ host: 'stage', hostname: 'prod.example.com' }
])
})
it('skips Host entries containing only wildcard and negated patterns', () => {
const config = `
Host !legacy *.corp ??
HostName ignored.example.com
`
expect(parseSshConfig(config)).toEqual([])
})
})