authelia/test/suites/HighAvailability/scenarii/AutheliaRestart.ts

52 lines
2.3 KiB
TypeScript
Raw Normal View History

2019-02-13 22:04:57 +00:00
import Logout from "../../../helpers/Logout";
import ChildProcess from 'child_process';
import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver";
import VerifySecretObserved from "../../../helpers/assertions/VerifySecretObserved";
import VisitPageAndWaitUrlIs from "../../../helpers/behaviors/VisitPageAndWaitUrlIs";
import { GET_Expect502 } from "../../../helpers/utils/Requests";
import LoginAndRegisterTotp from "../../../helpers/LoginAndRegisterTotp";
import FullLogin from "../../../helpers/FullLogin";
import ValidateTotp from "../../../helpers/ValidateTotp";
import VerifyUrlIs from "../../../helpers/assertions/WaitUrlIs";
2019-02-13 22:04:57 +00:00
export default function() {
describe('Session is still valid after Authelia restarts', function() {
before(async function() {
// Be sure to start fresh
ChildProcess.execSync('rm -f .authelia-interrupt');
this.driver = await StartDriver();
this.secret = await LoginAndRegisterTotp(this.driver, 'john', "password", true);
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/#/");
await ValidateTotp(this.driver, this.secret);
await VerifyUrlIs(this.driver, "https://home.example.com:8080/");
2019-02-13 22:04:57 +00:00
ChildProcess.execSync('touch .authelia-interrupt');
await GET_Expect502('https://login.example.com:8080/api/state');
await this.driver.sleep(1000);
ChildProcess.execSync('rm .authelia-interrupt');
2019-02-23 22:02:03 +00:00
await this.driver.sleep(4000);
2019-02-13 22:04:57 +00:00
});
after(async function() {
await Logout(this.driver);
await StopDriver(this.driver);
// Be sure to cleanup
ChildProcess.execSync('rm -f .authelia-interrupt');
});
it("should still access the secret after Authelia restarted", async function() {
await VisitPageAndWaitUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
await VerifySecretObserved(this.driver);
});
it("should still access the secret after Authelia restarted", async function() {
await Logout(this.driver);
2019-02-13 22:04:57 +00:00
// The user can re-authenticate with the secret.
await FullLogin(this.driver, 'john', this.secret, "https://admin.example.com:8080/secret.html");
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
await VerifySecretObserved(this.driver);
2019-02-13 22:04:57 +00:00
});
});
}