Personal Telegram developer console for GitHub
test: require approval signing fallback for existing production secret
davoodmehraban89 committed
Oct 3, 2026 at 06:01 UTC
d5b01d71c1cfb38c3337879f63e347b56fb9e8a6
1 file changed
+27
-2
test/approval-flow.test.js
+27
-2
@@ -74,8 +74,8 @@ function installMock() {
74
};
75
}
76
77
-async function sendUpdate(update) {
78
- const response = await worker.fetch(webhook(update), env);
77
+async function sendUpdate(update, runtime = env) {
78
+ const response = await worker.fetch(webhook(update), runtime);
79
assert.equal(response.status, 200);
80
return response.json();
81
}
@@ -164,3 +164,28 @@ test('approve callback executes exactly once and replay is rejected', async () =
164
mock.restore();
165
}
166
});
167
+
168
+test('WRITE approval falls back to the configured Telegram webhook secret when no dedicated signing secret exists', async () => {
169
+ const mock = installMock();
170
+ try {
171
+ const result = await sendUpdate({
172
+ callback_query: {
173
+ id: 'fallback-signing-secret',
174
+ from: { id: 123 },
175
+ data: 'rerun:1001:55',
176
+ message: { message_id: 702, chat: { id: 123 } }
177
+ }
178
+ }, {
179
+ ...env,
180
+ APPROVAL_SIGNING_SECRET: ''
181
+ });
182
+
183
+ assert.equal(result.ok, true);
184
+ assert.equal(result.approvalRequired, true);
185
+ assert.equal(mock.githubCalls.length, 0);
186
+ const edit = mock.telegramCalls.filter(call => call.method === 'editMessageText').at(-1);
187
+ assert.ok(edit.body.reply_markup.inline_keyboard.flat().some(button => String(button.callback_data || '').startsWith('approve:')));
188
+ } finally {
189
+ mock.restore();
190
+ }
191
+});