mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-10-09 17:08:58 +08:00
fix: 修复转换微信语音发送逻辑
This commit is contained in:
@@ -11,6 +11,7 @@ vi.mock('electron', () => ({
|
||||
}))
|
||||
|
||||
import {
|
||||
buildPersonalWechatVoiceDiagnostic,
|
||||
buildPersonalWechatOneBotRequest,
|
||||
findWechatImagePath,
|
||||
findPersonalWechatRuntime,
|
||||
@@ -32,6 +33,37 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('personal WeChat OneBot request', () => {
|
||||
it('keeps voice diagnostics to the safe metadata allowlist', () => {
|
||||
const diagnostic = buildPersonalWechatVoiceDiagnostic('request-1', 'completed', {
|
||||
input_bytes: 10,
|
||||
upload_result: '0',
|
||||
error: undefined,
|
||||
aesKey: 'secret',
|
||||
cdnKey: 'secret',
|
||||
token: 'secret',
|
||||
runtime_log: 'private'
|
||||
})
|
||||
expect(diagnostic).toMatchObject({ request_id: 'request-1', upload_result: '0' })
|
||||
expect(diagnostic).not.toHaveProperty('aesKey')
|
||||
expect(diagnostic).not.toHaveProperty('cdnKey')
|
||||
expect(diagnostic).not.toHaveProperty('token')
|
||||
expect(diagnostic).not.toHaveProperty('runtime_log')
|
||||
})
|
||||
|
||||
it('redacts secrets embedded in diagnostic errors', () => {
|
||||
const diagnostic = buildPersonalWechatVoiceDiagnostic('request-2', 'failed', {
|
||||
error:
|
||||
'upload failed aesKey=secret-value Bearer bearer-secret token:token-value {"cdnKey":"json-secret"}'
|
||||
})
|
||||
expect(diagnostic.error).toContain('aesKey=[redacted]')
|
||||
expect(diagnostic.error).toContain('Bearer [redacted]')
|
||||
expect(diagnostic.error).toContain('token:[redacted]')
|
||||
expect(diagnostic.error).not.toContain('secret-value')
|
||||
expect(diagnostic.error).not.toContain('bearer-secret')
|
||||
expect(diagnostic.error).not.toContain('token-value')
|
||||
expect(diagnostic.error).not.toContain('json-secret')
|
||||
})
|
||||
|
||||
it('builds a private text message request', () => {
|
||||
expect(
|
||||
buildPersonalWechatOneBotRequest({
|
||||
|
||||
Reference in New Issue
Block a user