runnerConfig.test.ts 2.0 KB

1234567891011121314151617181920212223242526272829
  1. // @vitest-environment node
  2. import {expect,it} from 'vitest'
  3. import {randomUUID} from 'node:crypto'
  4. import {parseRunnerConfiguration} from '../../src/runner/config'
  5. const config={protocol:1,runnerId:randomUUID(),token:'secret-fixture-'.repeat(3),serverURL:'https://example.invalid',hermesURL:'http://127.0.0.1:9119',allowedProfiles:['default'],artifactRoots:[]}
  6. it.each([
  7. {serverURL:'http://example.invalid'},
  8. {serverURL:'https://user:password@example.invalid'},
  9. {serverURL:'https://example.invalid/path'},
  10. {hermesURL:'http://host.docker.internal:9119'},
  11. {hermesURL:'http://user:password@127.0.0.1:9119'},
  12. {artifactRoots:['relative/path']},
  13. {allowedProfiles:['../default']},
  14. {protocol:2},
  15. {command:'/bin/sh'},
  16. ])('rejects invalid or expanded node configuration without echoing credentials (%j)',patch=>{
  17. expect(()=>parseRunnerConfiguration({...config,...patch})).toThrow()
  18. try{parseRunnerConfiguration({...config,...patch})}catch(error){expect(String(error)).not.toContain(config.token);expect(String(error)).not.toContain('password')}
  19. })
  20. it('accepts explicit LAN opt-in and keeps service credentials in the private configuration',()=>{
  21. expect(parseRunnerConfiguration({...config,serverURL:'http://192.168.1.2:15300',allowInsecureLan:true,hermesCredentials:{username:'fixture',password:'private'}})).toMatchObject({allowInsecureLan:true,hermesCredentials:{username:'fixture',password:'private'}})
  22. })
  23. it('keeps existing computer configurations offline unless public access is explicitly enabled',()=>{
  24. const computers={runtime:'docker',imageId:'sha256:'+ 'a'.repeat(64),python:'/fixture/python',hermesSource:'/fixture/source',hermesHome:'/fixture/home'}
  25. expect(parseRunnerConfiguration({...config,computers}).computers?.network).toBe('none')
  26. expect(parseRunnerConfiguration({...config,computers:{...computers,network:'public-proxy'}}).computers?.network).toBe('public-proxy')
  27. expect(()=>parseRunnerConfiguration({...config,computers:{...computers,network:'host'}})).toThrow()
  28. })