Personal Telegram developer console for GitHub
test: ensure temporary diag command is removed
davoodmehraban89 committed
Oct 2, 2026 at 19:04 UTC
e067b022a80b28506243b9203148e4ff01d01b19
1 file changed
+27
test/security.test.js
+27
@@ -100,3 +100,30 @@ test("temporary setup endpoint is disabled after webhook registration", async ()
100
assert.equal(res.status, 404);
101
assert.equal(calls, 0);
102
});
103
+
104
+test("temporary diagnostic command no longer exposes Telegram ID", async () => {
105
+ const req = telegramRequest("right", {
106
+ message: { text: "/diag", from: { id: 123 }, chat: { id: 123 } },
107
+ });
108
+
109
+ const messages = [];
110
+ globalThis.fetch = async (_url, options) => {
111
+ const payload = JSON.parse(options.body);
112
+ messages.push(payload.text);
113
+ return new Response(JSON.stringify({ ok: true }), {
114
+ status: 200,
115
+ headers: { "content-type": "application/json" },
116
+ });
117
+ };
118
+
119
+ const res = await worker.fetch(req, {
120
+ TELEGRAM_WEBHOOK_SECRET: "right",
121
+ OWNER_TELEGRAM_ID: "123",
122
+ TELEGRAM_BOT_TOKEN: "token",
123
+ });
124
+
125
+ assert.equal(res.status, 200);
126
+ assert.equal(messages.length, 1);
127
+ assert.match(messages[0], /فرمان شناخته نشد/);
128
+ assert.doesNotMatch(messages[0], /Telegram ID|123/);
129
+});