Expect retired consent path to be denied by MCP authentication middleware

This commit is contained in:
Admin 2026-10-08 04:42:15 +00:00
parent da08a36ba7
commit d1f09c4855

View File

@ -26,7 +26,8 @@ test('MCP middleware advertises Keycloak, denies anonymous tokens and isolates m
const base='http://127.0.0.1:'+server.address().port; const base='http://127.0.0.1:'+server.address().port;
try{ try{
const metadata=await(await fetch(base+'/.well-known/oauth-protected-resource/mcp')).json();assert.deepEqual(metadata.authorization_servers,[issuer]); const metadata=await(await fetch(base+'/.well-known/oauth-protected-resource/mcp')).json();assert.deepEqual(metadata.authorization_servers,[issuer]);
for(const path of ['/authorize','/token','/register','/mcp/consent'])assert.equal((await fetch(base+path)).status,404,path); for(const path of ['/authorize','/token','/register'])assert.equal((await fetch(base+path)).status,404,path);
assert.equal((await fetch(base+'/mcp/consent')).status,401,'Old consent path must not issue tokens');
const payload={jsonrpc:'2.0',id:1,method:'tools/list',params:{}}; const payload={jsonrpc:'2.0',id:1,method:'tools/list',params:{}};
const call=authorization=>fetch(base+'/mcp',{method:'POST',headers:{'content-type':'application/json',accept:'application/json, text/event-stream',...(authorization?{authorization}:{})},body:JSON.stringify(payload)}); const call=authorization=>fetch(base+'/mcp',{method:'POST',headers:{'content-type':'application/json',accept:'application/json, text/event-stream',...(authorization?{authorization}:{})},body:JSON.stringify(payload)});
assert.equal((await call()).status,401); assert.equal((await call()).status,401);