2019-01-31 05:33:14 +07:00
|
|
|
import LoginAndRegisterTotp from "../../../helpers/LoginAndRegisterTotp";
|
|
|
|
import ValidateTotp from "../../../helpers/ValidateTotp";
|
2019-02-13 05:41:19 +07:00
|
|
|
import VisitPageAndWaitUrlIs from "../../../helpers/behaviors/VisitPageAndWaitUrlIs";
|
2019-02-14 05:04:57 +07:00
|
|
|
import VisitPage from "../../../helpers/VisitPage";
|
|
|
|
import VerifyUrlIs from "../../../helpers/assertions/VerifyUrlIs";
|
2019-02-14 05:31:12 +07:00
|
|
|
import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver";
|
2019-04-25 04:52:08 +07:00
|
|
|
import ClickOnLink from "../../../helpers/ClickOnLink";
|
|
|
|
import FillLoginPageAndClick from "../../../helpers/FillLoginPageAndClick";
|
2019-01-31 05:33:14 +07:00
|
|
|
|
|
|
|
export default function(this: Mocha.ISuiteCallbackContext) {
|
2019-02-10 05:20:37 +07:00
|
|
|
this.timeout(20000);
|
2019-01-31 05:33:14 +07:00
|
|
|
|
|
|
|
beforeEach(async function() {
|
2019-02-14 05:31:12 +07:00
|
|
|
this.driver = await StartDriver();
|
2019-01-31 05:33:14 +07:00
|
|
|
});
|
|
|
|
|
2019-02-14 05:31:12 +07:00
|
|
|
afterEach(async function() {
|
|
|
|
await StopDriver(this.driver);
|
|
|
|
})
|
|
|
|
|
2019-04-25 04:52:08 +07:00
|
|
|
describe('Remember me not checked', function() {
|
|
|
|
beforeEach(async function() {
|
|
|
|
this.secret = await LoginAndRegisterTotp(this.driver, "john", "password", true);
|
|
|
|
});
|
2019-03-04 05:51:52 +07:00
|
|
|
|
2019-04-25 04:52:08 +07: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 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://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
|
|
|
|
});
|
|
|
|
|
|
|
|
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 ValidateTotp(this.driver, this.secret);
|
|
|
|
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
|
|
|
|
await this.driver.sleep(2000);
|
|
|
|
await VisitPageAndWaitUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await this.driver.sleep(2000);
|
|
|
|
await VisitPageAndWaitUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await this.driver.sleep(2000);
|
|
|
|
await VisitPageAndWaitUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await this.driver.sleep(2000);
|
|
|
|
await VisitPage(this.driver, "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-10 05:20:37 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('With remember me checkbox checked', function() {
|
2019-04-25 04:52:08 +07:00
|
|
|
beforeEach(async function() {
|
|
|
|
this.secret = await LoginAndRegisterTotp(this.driver, "john", "password", true);
|
|
|
|
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/#/");
|
|
|
|
await ClickOnLink(this.driver, "Logout");
|
|
|
|
});
|
|
|
|
|
2019-02-10 05:20:37 +07:00
|
|
|
it("should keep user logged in after inactivity period", async function() {
|
2019-03-04 05:51:52 +07:00
|
|
|
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080/secret.html");
|
2019-04-25 04:52:08 +07:00
|
|
|
await FillLoginPageAndClick(this.driver, "john", "password", true);
|
2019-03-04 05:51:52 +07:00
|
|
|
await ValidateTotp(this.driver, this.secret);
|
|
|
|
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
2019-04-25 04:52:08 +07:00
|
|
|
await VisitPageAndWaitUrlIs(this.driver, "https://home.example.com:8080/#/");
|
2019-03-22 22:54:27 +07:00
|
|
|
await this.driver.sleep(9000);
|
2019-03-04 05:51:52 +07:00
|
|
|
await VisitPage(this.driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
2019-02-10 05:20:37 +07:00
|
|
|
});
|
2019-01-31 05:33:14 +07:00
|
|
|
});
|
|
|
|
}
|