Skip to content

Commit 90f104d

Browse files
committed
test(desktop): an import entry's execution token travels in a header, never the URL
1 parent 2d13901 commit 90f104d

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎apps/desktop/src/main/desktop-executor/client.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DESKTOP_IMPORT_TOKEN_HEADER } from '@sim/desktop-bridge'
12
import { describe, expect, it } from 'vitest'
23
import { createDesktopExecutorClient, UnsendableRequestError } from '@/main/desktop-executor/client'
34

@@ -48,4 +49,38 @@ describe('desktop executor client', () => {
4849
const loneSurrogate = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/
4950
expect(loneSurrogate.test(sentMessage)).toBe(false)
5051
})
52+
53+
it('sends an import entry with its execution token in a header, never in the URL', async () => {
54+
const received: Array<{ url: string; token: string | null }> = []
55+
const client = createDesktopExecutorClient({
56+
origin: () => 'https://sim.test',
57+
fetch: async (url, init) => {
58+
received.push({ url, token: new Headers(init.headers).get(DESKTOP_IMPORT_TOKEN_HEADER) })
59+
return Response.json({ id: 'file-1', name: 'notes.txt' })
60+
},
61+
deviceId: '00000000-0000-4000-8000-000000000000',
62+
})
63+
64+
await client.importEntry(
65+
{
66+
call: {
67+
toolCallId: 'call-1',
68+
toolName: 'import_local_files',
69+
args: {},
70+
chatId: 'chat-1',
71+
workspaceId: 'ws-1',
72+
executionToken: 'secret-token-1',
73+
},
74+
kind: 'file',
75+
sourceName: 'notes.txt',
76+
relativePath: '',
77+
content: new Blob(['hello']),
78+
},
79+
new AbortController().signal
80+
)
81+
82+
expect(received).toHaveLength(1)
83+
expect(received[0]?.token).toBe('secret-token-1')
84+
expect(decodeURIComponent(received[0]?.url ?? '')).not.toContain('secret-token-1')
85+
})
5186
})

0 commit comments

Comments
 (0)