2019-01-30 22:47:03 +07:00
|
|
|
|
|
|
|
import ChildProcess from 'child_process';
|
|
|
|
|
2019-01-31 04:44:03 +07:00
|
|
|
export default function WithAutheliaRunning(configPath: string, waitTimeout: number = 3000) {
|
2019-01-30 22:47:03 +07:00
|
|
|
before(function() {
|
|
|
|
this.timeout(5000);
|
|
|
|
const authelia = ChildProcess.spawn(
|
|
|
|
'./scripts/authelia-scripts',
|
2019-01-31 04:44:03 +07:00
|
|
|
['serve', '--no-watch', '--config', configPath],
|
2019-01-30 22:47:03 +07:00
|
|
|
{detached: true});
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|