mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 11:43:17 +08:00
fix: add actionable DingTalk connection diagnostics
This commit is contained in:
parent
3010535409
commit
1b05fa8d32
18 changed files with 1038 additions and 299 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
createDingtalkRpcHandler,
|
||||
installDingtalkRpc,
|
||||
} from '../../../plugin-src/host/channels/dingtalk/rpc.mjs';
|
||||
import { dingtalkPublicConnectionError } from '../../../src/channels/dingtalk/connection-error.mjs';
|
||||
|
||||
function controller(overrides = {}) {
|
||||
return {
|
||||
|
|
@ -96,6 +97,28 @@ test('credential RPC accepts Client ID fields while keeping Client Secret host-o
|
|||
assert.equal((await handler(DINGTALK_ENDPOINTS.bindCredentials, { clientId: 'manual-client' })).ok, false);
|
||||
});
|
||||
|
||||
test('RPC returns only the safe connection diagnostic projection', async () => {
|
||||
const cause = new Error('request body contains clientSecret=must-not-leak');
|
||||
const publicError = {
|
||||
code: 'stream-proxy-dependency-incompatible',
|
||||
message: '钉钉 Stream 连接失败。',
|
||||
hint: '请修复代理依赖后重试。',
|
||||
referenceId: 'DT-CONN-DEADBEEF',
|
||||
};
|
||||
const handler = createDingtalkRpcHandler(controller({
|
||||
reconnectBot: async () => {
|
||||
throw dingtalkPublicConnectionError(publicError, cause);
|
||||
},
|
||||
}));
|
||||
|
||||
const result = await handler(DINGTALK_ENDPOINTS.reconnectBot, {
|
||||
botId: 'dt_abc', sendTest: true,
|
||||
});
|
||||
|
||||
assert.deepEqual(result, { ok: false, error: publicError });
|
||||
assert.doesNotMatch(JSON.stringify(result), /must-not-leak|clientSecret|cause/);
|
||||
});
|
||||
|
||||
test('RPC is registered for loopback clients only', () => {
|
||||
const registrations = [];
|
||||
const dispose = () => {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue