authelia/test/suites/HighAvailability/scenarii/AutheliaRestart.ts
Clement Michaud a991379a74 Declare suites as Go structs and bootstrap e2e test framework in Go.
Some tests are not fully rewritten in Go, a typescript wrapper is called
instead until we remove the remaining TS tests and dependencies.

Also, dockerize every components (mainly Authelia backend, frontend and kind)
so that the project does not interfere with user host anymore (open ports for instance).
The only remaining intrusive change is the one done during bootstrap to add entries in /etc/hosts.
It will soon be avoided using authelia.com domain that I own.
2019-11-15 20:23:06 +01:00

52 lines
2.3 KiB
TypeScript

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";
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/");
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');
await this.driver.sleep(4000);
});
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);
// 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);
});
});
}