Import packages/plugin/tests/harness-remote-bridge.test.ts
This commit is contained in:
parent
47afe32aff
commit
ecdf969dce
|
|
@ -1484,7 +1484,30 @@ describe('HarnessRemoteBridge', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'rejects readBytes when path is not relative when baseFile is provided',
|
name: 'resolves readBytes when the path is absolute inside the workspace even with baseFile',
|
||||||
|
run: async () => {
|
||||||
|
dispatch.mockClear()
|
||||||
|
await expect(
|
||||||
|
bridge.call({
|
||||||
|
endpoint: 'workspaceFiles/readBytes',
|
||||||
|
payload: {
|
||||||
|
args: {
|
||||||
|
workspaceFileScopeId: 'session-1',
|
||||||
|
path: insideFile,
|
||||||
|
options: { baseFile: 'sub/nested.txt' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).resolves.toMatchObject({ ok: true })
|
||||||
|
expect(dispatch).toHaveBeenCalledWith(
|
||||||
|
'workspaceFiles/readBytes',
|
||||||
|
expect.objectContaining({ args: expect.objectContaining({ path: 'inside.txt' }) }),
|
||||||
|
expect.any(AbortSignal),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'rejects readBytes when an absolute path stays outside the workspace with baseFile',
|
||||||
run: async () => {
|
run: async () => {
|
||||||
dispatch.mockClear()
|
dispatch.mockClear()
|
||||||
await expect(
|
await expect(
|
||||||
|
|
@ -1500,7 +1523,12 @@ describe('HarnessRemoteBridge', () => {
|
||||||
}),
|
}),
|
||||||
).rejects.toMatchObject({ code: 'WORKSPACE_PATH_DENIED' })
|
).rejects.toMatchObject({ code: 'WORKSPACE_PATH_DENIED' })
|
||||||
expect(dispatch).not.toHaveBeenCalled()
|
expect(dispatch).not.toHaveBeenCalled()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'rejects readBytes when the path carries a URL scheme with baseFile',
|
||||||
|
run: async () => {
|
||||||
|
dispatch.mockClear()
|
||||||
await expect(
|
await expect(
|
||||||
bridge.call({
|
bridge.call({
|
||||||
endpoint: 'workspaceFiles/readBytes',
|
endpoint: 'workspaceFiles/readBytes',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue