authelia/test/suites/short-timeouts/scenarii/Inactivity.ts

61 lines
3.3 KiB
TypeScript
Raw Normal View History

2019-01-30 22:33:14 +00:00
import LoginAndRegisterTotp from "../../../helpers/LoginAndRegisterTotp";
import FillLoginPageWithUserAndPasswordAndClick from "../../../helpers/FillLoginPageAndClick";
import ValidateTotp from "../../../helpers/ValidateTotp";
import VisitPageAndWaitUrlIs from "../../../helpers/behaviors/VisitPageAndWaitUrlIs";
2019-02-13 22:04:57 +00:00
import VisitPage from "../../../helpers/VisitPage";
import VerifyUrlIs from "../../../helpers/assertions/VerifyUrlIs";
2019-02-13 22:31:12 +00:00
import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver";
2019-01-30 22:33:14 +00:00
export default function(this: Mocha.ISuiteCallbackContext) {
2019-02-09 22:20:37 +00:00
this.timeout(20000);
2019-01-30 22:33:14 +00:00
beforeEach(async function() {
2019-02-13 22:31:12 +00:00
this.driver = await StartDriver();
this.secret = await LoginAndRegisterTotp(this.driver, "john", "password", true);
2019-01-30 22:33:14 +00:00
});
2019-02-13 22:31:12 +00:00
afterEach(async function() {
await StopDriver(this.driver);
})
2019-01-30 22:33:14 +00:00
it("should disconnect user after inactivity period", async function() {
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'password', false);
await ValidateTotp(this.driver, this.secret);
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
await VisitPageAndWaitUrlIs(this.driver, "https://home.example.com:8080/");
await this.driver.sleep(6000);
await this.driver.get("https://admin.example.com:8080/secret.html");
await VerifyUrlIs(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
2019-01-30 22:33:14 +00:00
});
2019-02-09 22:20:37 +00:00
it('should disconnect user after cookie expiration', async function() {
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'password', false);
await ValidateTotp(this.driver, this.secret);
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
await VisitPageAndWaitUrlIs(this.driver, "https://home.example.com:8080/");
await this.driver.sleep(4000);
await this.driver.get("https://admin.example.com:8080/secret.html");
await this.driver.sleep(2000);
await this.driver.get("https://admin.example.com:8080/secret.html");
await this.driver.sleep(2000);
await this.driver.get("https://admin.example.com:8080/secret.html");
await VerifyUrlIs(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
2019-02-09 22:20:37 +00:00
});
describe('With remember me checkbox checked', function() {
it("should keep user logged in after inactivity period", async function() {
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'password', true);
await ValidateTotp(this.driver, this.secret);
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
await VisitPageAndWaitUrlIs(this.driver, "https://home.example.com:8080/");
await this.driver.sleep(6000);
await VisitPage(this.driver, "https://admin.example.com:8080/secret.html");
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
2019-02-09 22:20:37 +00:00
});
2019-01-30 22:33:14 +00:00
});
}