chore: 保存 Agent 安全优化前基线
This commit is contained in:
1 parent
08696896f9
commit
ff016347cd
116 files changed
+3858
-2485
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushShellBootstrap } from '../../src/utils/shellIO'
|
||||
|
||||
describe('flushShellBootstrap', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(window.opsxApi.localOpenOutput).mockClear()
|
||||
vi.mocked(window.opsxApi.sshShellOpenOutput).mockClear()
|
||||
vi.mocked(window.opsxApi.localOpenOutput).mockResolvedValue({
|
||||
success: true,
|
||||
data: [98, 97, 115, 104],
|
||||
})
|
||||
vi.mocked(window.opsxApi.sshShellOpenOutput).mockResolvedValue({
|
||||
success: true,
|
||||
data: [109, 111, 116, 100],
|
||||
})
|
||||
})
|
||||
|
||||
it('opens buffered local PTY output for local-* ids', async () => {
|
||||
const boot = await flushShellBootstrap('local-abc')
|
||||
expect(window.opsxApi.localOpenOutput).toHaveBeenCalledWith('local-abc')
|
||||
expect(window.opsxApi.sshShellOpenOutput).not.toHaveBeenCalled()
|
||||
expect(boot).toEqual(new Uint8Array([98, 97, 115, 104]))
|
||||
})
|
||||
|
||||
it('opens buffered SSH output for remote shell ids', async () => {
|
||||
const boot = await flushShellBootstrap('shell-abc')
|
||||
expect(window.opsxApi.sshShellOpenOutput).toHaveBeenCalledWith('shell-abc')
|
||||
expect(window.opsxApi.localOpenOutput).not.toHaveBeenCalled()
|
||||
expect(boot).toEqual(new Uint8Array([109, 111, 116, 100]))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user