mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 10:27:46 +08:00
Merge remote-tracking branch 'origin/pr/498'
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { normalizeBatchImportCredentials } from '@/api/endpoints/provider_oauth'
|
||||
import { isKeyManagedProviderType, isOAuthAccountProviderType } from '../providerTypeUtils'
|
||||
|
||||
describe('providerTypeUtils', () => {
|
||||
@@ -14,4 +15,47 @@ describe('providerTypeUtils', () => {
|
||||
expect(isOAuthAccountProviderType('GROK')).toBe(true)
|
||||
expect(isKeyManagedProviderType('grok')).toBe(false)
|
||||
})
|
||||
|
||||
it('treats Windsurf as an OAuth account provider', () => {
|
||||
expect(isOAuthAccountProviderType('windsurf')).toBe(true)
|
||||
expect(isOAuthAccountProviderType('Windsurf')).toBe(true)
|
||||
expect(isKeyManagedProviderType('windsurf')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('normalizeBatchImportCredentials', () => {
|
||||
it('converts JSON Lines objects into a JSON array payload', () => {
|
||||
const result = normalizeBatchImportCredentials([
|
||||
'{"refresh_token":"rt-1","email":"[email protected]"}',
|
||||
'{"token":"token-2","email":"[email protected]"}',
|
||||
].join('\n'))
|
||||
|
||||
expect(result).toEqual({
|
||||
ok: true,
|
||||
isBatch: true,
|
||||
credentials: JSON.stringify([
|
||||
{ refresh_token: 'rt-1', email: '[email protected]' },
|
||||
{ token: 'token-2', email: '[email protected]' },
|
||||
]),
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects malformed JSON Lines instead of treating them as raw tokens', () => {
|
||||
const result = normalizeBatchImportCredentials('{"refresh_token":"rt-1"}\n{"refresh_token":')
|
||||
|
||||
expect(result.ok).toBe(false)
|
||||
if (!result.ok) {
|
||||
expect(result.message).toContain('第 2 行')
|
||||
}
|
||||
})
|
||||
|
||||
it('converts multiple raw token lines into a JSON array payload', () => {
|
||||
const result = normalizeBatchImportCredentials('token-a\n# comment\ntoken-b')
|
||||
|
||||
expect(result).toEqual({
|
||||
ok: true,
|
||||
isBatch: true,
|
||||
credentials: JSON.stringify(['token-a', 'token-b']),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ const oauthAccountProviderTypes = new Set([
|
||||
'antigravity',
|
||||
'kiro',
|
||||
'grok',
|
||||
'windsurf',
|
||||
])
|
||||
|
||||
export const isOAuthAccountProviderType = (providerType?: string | null): boolean =>
|
||||
|
||||
Reference in New Issue
Block a user