runnerConfig.test.ts 1.4 KB

12345678910111213141516171819202122
  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. })