fix: reject unconfirmed Telegram tests and invalid update responses
This commit is contained in:
@@ -54,3 +54,15 @@ test('matching accepts only a fresh exact code from a private non-bot sender',as
|
||||
updates=[{message:{...good,text:'/start '+code}}];assert.equal((await kodIleBagla(code,window)).ad,'QA');
|
||||
} finally {globalThis.fetch=oldFetch;if(oldToken===undefined)delete process.env.TELEGRAM_BOT_TOKEN;else process.env.TELEGRAM_BOT_TOKEN=oldToken;}
|
||||
});
|
||||
|
||||
test('provider errors and malformed updates are not treated as code-not-found results',async()=>{
|
||||
const oldFetch=globalThis.fetch,oldToken=process.env.TELEGRAM_BOT_TOKEN;
|
||||
process.env.TELEGRAM_BOT_TOKEN='synthetic-token';
|
||||
const window={issuedAt:1000000,expiresAt:1600000,now:1100000};
|
||||
try {
|
||||
for(const [ok,body] of [[false,{ok:true,result:[]}],[true,{ok:true}],[true,{ok:true,result:{}}],[true,{ok:'true',result:[]}]]){
|
||||
globalThis.fetch=async()=>({ok,json:async()=>body});
|
||||
await assert.rejects(kodIleBagla('a'.repeat(48),window),/yanıtı doğrulanamadı/);
|
||||
}
|
||||
}finally{globalThis.fetch=oldFetch;if(oldToken===undefined)delete process.env.TELEGRAM_BOT_TOKEN;else process.env.TELEGRAM_BOT_TOKEN=oldToken;}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user