2019-01-30 22:33:14 +00:00
|
|
|
import LoginAndRegisterTotp from "../../../helpers/LoginAndRegisterTotp";
|
|
|
|
import VisitPage from "../../../helpers/VisitPage";
|
|
|
|
import FillLoginPageWithUserAndPasswordAndClick from "../../../helpers/FillLoginPageAndClick";
|
|
|
|
import ValidateTotp from "../../../helpers/ValidateTotp";
|
|
|
|
import WaitRedirected from "../../../helpers/WaitRedirected";
|
2019-02-09 22:20:37 +00:00
|
|
|
import { WebDriver } from "selenium-webdriver";
|
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() {
|
|
|
|
this.secret = await LoginAndRegisterTotp(this.driver, "john", true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should disconnect user after inactivity period", async function() {
|
2019-02-09 22:20:37 +00:00
|
|
|
const driver = this.driver as WebDriver;
|
2019-01-30 22:33:14 +00:00
|
|
|
await VisitPage(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
|
|
|
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', false);
|
|
|
|
await ValidateTotp(driver, this.secret);
|
|
|
|
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await VisitPage(driver, "https://home.example.com:8080/");
|
|
|
|
await driver.sleep(6000);
|
|
|
|
await driver.get("https://admin.example.com:8080/secret.html");
|
|
|
|
await WaitRedirected(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
|
|
|
});
|
|
|
|
|
2019-02-09 22:20:37 +00:00
|
|
|
it('should disconnect user after cookie expiration', async function() {
|
|
|
|
const driver = this.driver as WebDriver;
|
2019-01-30 22:33:14 +00:00
|
|
|
await VisitPage(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
2019-02-09 22:20:37 +00:00
|
|
|
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', false);
|
2019-01-30 22:33:14 +00:00
|
|
|
await ValidateTotp(driver, this.secret);
|
|
|
|
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await VisitPage(driver, "https://home.example.com:8080/");
|
2019-02-09 22:20:37 +00:00
|
|
|
|
|
|
|
await driver.sleep(4000);
|
2019-01-30 22:33:14 +00:00
|
|
|
await driver.get("https://admin.example.com:8080/secret.html");
|
2019-02-09 22:20:37 +00:00
|
|
|
await driver.sleep(2000);
|
|
|
|
await driver.get("https://admin.example.com:8080/secret.html");
|
|
|
|
|
|
|
|
await driver.sleep(2000);
|
|
|
|
await driver.get("https://admin.example.com:8080/secret.html");
|
|
|
|
await WaitRedirected(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With remember me checkbox checked', function() {
|
|
|
|
it("should keep user logged in after inactivity period", async function() {
|
|
|
|
const driver = this.driver as WebDriver;
|
|
|
|
await VisitPage(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
|
|
|
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', true);
|
|
|
|
await ValidateTotp(driver, this.secret);
|
|
|
|
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
await VisitPage(driver, "https://home.example.com:8080/");
|
|
|
|
await driver.sleep(6000);
|
|
|
|
await driver.get("https://admin.example.com:8080/secret.html");
|
|
|
|
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
|
|
|
});
|
2019-01-30 22:33:14 +00:00
|
|
|
});
|
|
|
|
}
|