Skip to content

Repository files, collaboration, releases and project activity.

ARCHFORGE HISTORY

Blame · tests/probes.test.js

Branch main · the Commit author is not necessarily a verified ArchForge account.

e59b7f7cc6archadmin2026-10-111 'use strict';
e59b7f7cc6archadmin2026-10-112 const test=require('node:test'),assert=require('node:assert/strict'),http=require('node:http');const {checkHttp,serviceDefinitions}=require('../src/probes');
2109dd33b8archadmin2026-10-123 test('HTTP probe rejects redirects and HTTP 200 pages at ArchForge discovery without ArchForge content type',async()=>{
e59b7f7cc6archadmin2026-10-114  const server=http.createServer((req,res)=>{
e59b7f7cc6archadmin2026-10-115  if(req.url==='/redirect'){res.writeHead(302,{Location:'/ok'});res.end();return;}
e59b7f7cc6archadmin2026-10-116  if(req.url==='/git'){res.writeHead(200,{'content-type':'text/html'});res.end('<html>Login</html>');return;}
e59b7f7cc6archadmin2026-10-117  res.writeHead(200,{'content-type':'text/plain'});res.end('OK');
e59b7f7cc6archadmin2026-10-118  });
e59b7f7cc6archadmin2026-10-119  await new Promise(r=>server.listen(0,'127.0.0.1',r));const base='http://127.0.0.1:'+server.address().port;
e59b7f7cc6archadmin2026-10-1110  try{assert.equal((await checkHttp(base+'/redirect',1000)).success,false);assert.equal((await checkHttp(base+'/git',1000,{git:true})).success,false);assert.equal((await checkHttp(base+'/ok',1000)).success,true);}finally{await new Promise(r=>server.close(r));}
e59b7f7cc6archadmin2026-10-1111 });
2109dd33b8archadmin2026-10-1212 test('optional ArchForge HTTPS and API are disabled when not configured',()=>{const c={api:'',gitHttp:''};const s=serviceDefinitions(c);assert.equal(s.find(v=>v.id==='api').configured,false);assert.equal(s.find(v=>v.id==='git_http').configured,false);});