Files
opsxshell/test/utils/connectionFingerprint.test.ts
T
Logan.LiandCursor fea6d8db04 feat: Pro 买断门禁、SFTP 精简与批量多机改造
新增 entitlement/license IPC 与 Waffo 一次性结账服务骨架,挂载 AI/转发/代理/串口/广播/批量导入导出门禁;批量执行改为结果矩阵并复用连接池,SFTP 工具栏图标化并去掉已连接条,同时完善跨平台本地终端与窗口配置。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 11:38:30 +08:00

54 lines
1.8 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { connectionReuseFingerprint } from '../../src/utils/connectionFingerprint'
import type { SSHConnectionConfig } from '../../shared/types/session.types'
const base = (): SSHConnectionConfig => ({
host: 'example.com',
port: 22,
username: 'root',
authType: 'password',
password: 'secret',
})
describe('connectionReuseFingerprint', () => {
it('matches identical configs', () => {
expect(connectionReuseFingerprint(base())).toBe(connectionReuseFingerprint(base()))
})
it('differs when password presence changes', () => {
const a = base()
const b = { ...base(), password: undefined, authType: 'agent' as const }
expect(connectionReuseFingerprint(a)).not.toBe(connectionReuseFingerprint(b))
})
it('differs when private key path differs', () => {
const a = { ...base(), authType: 'key' as const, password: undefined, privateKey: '/a' }
const b = { ...base(), authType: 'key' as const, password: undefined, privateKey: '/b' }
expect(connectionReuseFingerprint(a)).not.toBe(connectionReuseFingerprint(b))
})
it('differs when proxy differs', () => {
const a = {
...base(),
proxy: { type: 'socks5' as const, host: '127.0.0.1', port: 1080 },
}
const b = {
...base(),
proxy: { type: 'http' as const, host: '127.0.0.1', port: 8080 },
}
expect(connectionReuseFingerprint(a)).not.toBe(connectionReuseFingerprint(b))
})
it('differs when jump host differs', () => {
const a = {
...base(),
jumpHost: { host: 'bastion', username: 'jump', authType: 'password' as const, password: 'x' },
}
const b = {
...base(),
jumpHost: { host: 'other', username: 'jump', authType: 'password' as const, password: 'x' },
}
expect(connectionReuseFingerprint(a)).not.toBe(connectionReuseFingerprint(b))
})
})