mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-30 00:21:34 +00:00
fix(grok): 修正授权与模型映射边界
This commit is contained in:
@@ -8,7 +8,7 @@ vi.mock('@/api/client', () => ({
|
||||
apiClient: { post },
|
||||
}))
|
||||
|
||||
import { createFromSSO, getGrokSSOImportTimeout } from '@/api/admin/grok'
|
||||
import { authorizePassword, createFromSSO, getGrokSSOImportTimeout } from '@/api/admin/grok'
|
||||
|
||||
describe('admin Grok SSO import API', () => {
|
||||
beforeEach(() => {
|
||||
@@ -34,4 +34,20 @@ describe('admin Grok SSO import API', () => {
|
||||
{ timeout: expectedTimeout },
|
||||
)
|
||||
})
|
||||
|
||||
it('preserves password whitespace and applies the authorization timeout', async () => {
|
||||
post.mockResolvedValueOnce({ data: { access_token: 'access-token' } })
|
||||
|
||||
await authorizePassword(' user@example.com ---- password with spaces ', 7)
|
||||
|
||||
expect(post).toHaveBeenCalledWith(
|
||||
'/admin/grok/oauth/password',
|
||||
{
|
||||
email: 'user@example.com',
|
||||
password: ' password with spaces ',
|
||||
proxy_id: 7,
|
||||
},
|
||||
{ timeout: 120_000 },
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5488,8 +5488,9 @@ const handleGrokAuthorizePassword = async (emailPasswordInput: string) => {
|
||||
|
||||
const lines = emailPasswordInput
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => line && line.includes('----'))
|
||||
// Keep the password portion byte-for-byte; trim is only for determining
|
||||
// whether this textarea line is blank.
|
||||
.filter((line) => line.trim() && line.includes('----'))
|
||||
|
||||
if (lines.length === 0) {
|
||||
grokOAuth.error.value = t(
|
||||
|
||||
@@ -678,8 +678,8 @@ const handleGrokAuthorizePassword = async (emailPasswordInput: string) => {
|
||||
if (!props.account || !isGrok.value) return
|
||||
const line = emailPasswordInput
|
||||
.split('\n')
|
||||
.map((item) => item.trim())
|
||||
.find((item) => item.includes('----'))
|
||||
// Email is normalized in the API helper, but password whitespace is valid.
|
||||
.find((item) => item.trim() && item.includes('----'))
|
||||
if (!line) {
|
||||
grokOAuth.error.value = t(
|
||||
'admin.accounts.oauth.grok.pleaseEnterPassword',
|
||||
|
||||
Reference in New Issue
Block a user