Personal Telegram developer console for GitHub

test: require approval signing secret redaction

davoodmehraban89 committed Oct 3, 2026 at 06:03 UTC a4cd07ee862ca9bae563de1604a3799581a8d1d5
1 file changed +9 -3
test/index.test.js
+9 -3
@@ -92,15 +92,19 @@ describe('Nexa Dev Bot - Cloudflare Worker Entrypoint', () => {
92 assert.equal(res.status, 404);
93 });
94
95 - it('logs Telegram webhook processing failures without exposing the bot token', async () => {
95 + it('logs Telegram webhook processing failures without exposing configured secrets', async () => {
96 const originalFetch = globalThis.fetch;
97 const originalError = console.error;
98 const logs = [];
99 const secretToken = 'telegram-secret-token-for-test';
100 + const approvalSecret = 'approval-secret-for-test';
101
102 globalThis.fetch = async (url) => {
103 if (String(url).startsWith('https://api.telegram.org/')) {
103 - return new Response(JSON.stringify({ ok: false, description: 'Unauthorized' }), {
104 + return new Response(JSON.stringify({
105 + ok: false,
106 + description: `Unauthorized ${approvalSecret}`
107 + }), {
108 status: 401,
109 headers: { 'content-type': 'application/json' }
110 });
@@ -112,12 +116,14 @@ describe('Nexa Dev Bot - Cloudflare Worker Entrypoint', () => {
116 try {
117 const res = await worker.fetch(webhookRequest(), {
118 ...runtime,
115 - TELEGRAM_BOT_TOKEN: secretToken
119 + TELEGRAM_BOT_TOKEN: secretToken,
120 + APPROVAL_SIGNING_SECRET: approvalSecret
121 });
122 assert.equal(res.status, 400);
123 assert.ok(logs.some(line => /telegram_webhook_error/i.test(line)));
124 assert.ok(logs.some(line => /401|Unauthorized/i.test(line)));
125 assert.ok(logs.every(line => !line.includes(secretToken)));
126 + assert.ok(logs.every(line => !line.includes(approvalSecret)));
127 } finally {
128 globalThis.fetch = originalFetch;
129 console.error = originalError;