fix(desktop): isolate AI account auth probes
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import { beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const probeAIAccountSession = vi.fn()
|
||||
const probePublishAccountSession = vi.fn()
|
||||
const silentRefreshAIAccountSession = vi.fn()
|
||||
const silentRefreshPublishAccountSession = vi.fn()
|
||||
|
||||
vi.mock('./account-binder', () => ({
|
||||
probePublishAccountSession: vi.fn(),
|
||||
silentRefreshPublishAccountSession: vi.fn(),
|
||||
probeAIAccountSession,
|
||||
probePublishAccountSession,
|
||||
silentRefreshAIAccountSession,
|
||||
silentRefreshPublishAccountSession,
|
||||
}))
|
||||
|
||||
let getPlatformAdapter: typeof import('./platform-auth-adapters').getPlatformAdapter
|
||||
@@ -12,6 +19,47 @@ beforeAll(async () => {
|
||||
})
|
||||
|
||||
describe('platform auth adapters', () => {
|
||||
it('routes AI account probes away from publish account probes', async () => {
|
||||
probeAIAccountSession.mockResolvedValueOnce({
|
||||
verdict: 'active',
|
||||
reason: 'probe_success',
|
||||
profile: null,
|
||||
sessionFingerprint: 'ai-session',
|
||||
})
|
||||
const adapter = getPlatformAdapter('doubao')
|
||||
|
||||
await adapter.probe(
|
||||
{
|
||||
id: 'account-1',
|
||||
platform: 'doubao',
|
||||
platformUid: 'doubao-session:demo',
|
||||
displayName: 'Geek',
|
||||
},
|
||||
'persist:test',
|
||||
)
|
||||
|
||||
expect(probeAIAccountSession).toHaveBeenCalledTimes(1)
|
||||
expect(probePublishAccountSession).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('routes AI silent refresh away from publish account refresh', async () => {
|
||||
silentRefreshAIAccountSession.mockResolvedValueOnce(true)
|
||||
const adapter = getPlatformAdapter('qwen')
|
||||
|
||||
await adapter.silentRefresh(
|
||||
{
|
||||
id: 'account-2',
|
||||
platform: 'qwen',
|
||||
platformUid: 'qwen-session:demo',
|
||||
displayName: '通义千问账号',
|
||||
},
|
||||
'persist:test',
|
||||
)
|
||||
|
||||
expect(silentRefreshAIAccountSession).toHaveBeenCalledTimes(1)
|
||||
expect(silentRefreshPublishAccountSession).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('classifies Wenxin environment abnormal messages as risk control', () => {
|
||||
const adapter = getPlatformAdapter('wenxin')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user