Personal Telegram developer console for GitHub
test: restore setup endpoint lock regression
davoodmehraban89 committed
Oct 2, 2026 at 19:37 UTC
66ca44e51eb4b1ac2032cd9ad7b25e8e768a0d32
1 file changed
+20
test/security.test.js
+20
@@ -81,6 +81,26 @@ test("unauthorized Telegram users receive no bot response", async () => {
81
assert.equal(calls, 0);
82
});
83
84
+test("temporary setup endpoint is disabled after webhook registration", async () => {
85
+ const req = new Request("https://nexa-dev-bot.example.workers.dev/telegram/setup", {
86
+ method: "GET",
87
+ });
88
+
89
+ let calls = 0;
90
+ globalThis.fetch = async () => {
91
+ calls += 1;
92
+ throw new Error("setup endpoint must not call Telegram after registration");
93
+ };
94
+
95
+ const res = await worker.fetch(req, {
96
+ TELEGRAM_WEBHOOK_SECRET: "secret",
97
+ TELEGRAM_BOT_TOKEN: "token",
98
+ });
99
+
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 } },