mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-04-22 06:38:39 +00:00
fix: align claude-console test auth with relay logic
This commit is contained in:
@@ -32,7 +32,7 @@ describe('claudeConsoleRelayService.testAccountConnection', () => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('passes selected model stream payload to sendStreamTestRequest', async () => {
|
||||
it('passes selected model stream payload and bearer auth for non sk-ant key', async () => {
|
||||
claudeConsoleAccountService.getAccount.mockResolvedValue({
|
||||
name: 'Console A1',
|
||||
apiUrl: 'https://console.example.com',
|
||||
@@ -55,8 +55,42 @@ describe('claudeConsoleRelayService.testAccountConnection', () => {
|
||||
expect(createClaudeTestPayload).toHaveBeenCalledWith('claude-sonnet-4-6', { stream: true })
|
||||
expect(sendStreamTestRequest).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
payload
|
||||
payload,
|
||||
authorization: 'Bearer test-key'
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('passes selected model stream payload and x-api-key for sk-ant key', async () => {
|
||||
claudeConsoleAccountService.getAccount.mockResolvedValue({
|
||||
name: 'Console A1',
|
||||
apiUrl: 'https://console.example.com',
|
||||
apiKey: 'sk-ant-test-key',
|
||||
proxy: null,
|
||||
userAgent: null
|
||||
})
|
||||
claudeConsoleAccountService._createProxyAgent.mockReturnValue(undefined)
|
||||
|
||||
const payload = {
|
||||
model: 'claude-sonnet-4-6',
|
||||
stream: true
|
||||
}
|
||||
createClaudeTestPayload.mockReturnValue(payload)
|
||||
sendStreamTestRequest.mockResolvedValue(undefined)
|
||||
|
||||
const res = {}
|
||||
await claudeConsoleRelayService.testAccountConnection('a1', res, 'claude-sonnet-4-6')
|
||||
|
||||
expect(createClaudeTestPayload).toHaveBeenCalledWith('claude-sonnet-4-6', { stream: true })
|
||||
const requestOptions = sendStreamTestRequest.mock.calls[0][0]
|
||||
expect(requestOptions).toEqual(
|
||||
expect.objectContaining({
|
||||
payload,
|
||||
extraHeaders: expect.objectContaining({
|
||||
'x-api-key': 'sk-ant-test-key'
|
||||
})
|
||||
})
|
||||
)
|
||||
expect(requestOptions).not.toHaveProperty('authorization')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user