2019-01-30 15:47:03 +00:00
|
|
|
|
|
|
|
import ChildProcess from 'child_process';
|
|
|
|
|
2019-01-30 21:44:03 +00:00
|
|
|
export default function WithAutheliaRunning(configPath: string, waitTimeout: number = 3000) {
|
2019-01-30 15:47:03 +00:00
|
|
|
before(function() {
|
|
|
|
this.timeout(5000);
|
|
|
|
const authelia = ChildProcess.spawn(
|
|
|
|
'./scripts/authelia-scripts',
|
2019-01-30 21:44:03 +00:00
|
|
|
['serve', '--no-watch', '--config', configPath],
|
2019-01-30 15:47:03 +00:00
|
|
|
{detached: true});
|
2019-02-04 22:23:59 +00:00
|
|
|
|
|
|
|
authelia.on('exit', function() {
|
|
|
|
console.log('Server terminated.');
|
|
|
|
});
|
2019-01-30 15:47:03 +00:00
|
|
|
this.authelia = authelia;
|
|
|
|
|
|
|
|
const waitPromise = new Promise((resolve, reject) => setTimeout(() => resolve(), waitTimeout));
|
|
|
|
return waitPromise;
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function() {
|
|
|
|
this.timeout(1000);
|
|
|
|
|
|
|
|
// Kill the group of processes.
|
|
|
|
process.kill(-this.authelia.pid);
|
|
|
|
});
|
|
|
|
}
|