diff --git a/test/suites/minimal/scenarii/BadPassword.ts b/test/suites/minimal/scenarii/BadPassword.ts index ddd4d51b..44865753 100644 --- a/test/suites/minimal/scenarii/BadPassword.ts +++ b/test/suites/minimal/scenarii/BadPassword.ts @@ -2,6 +2,7 @@ import FillLoginPageWithUserAndPasswordAndClick from '../../../helpers/FillLogin import {AUTHENTICATION_FAILED} from '../../../../shared/UserMessages'; import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs'; import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed'; +import { StartDriver, StopDriver } from '../../../helpers/context/WithDriver'; export default function() { /** @@ -9,14 +10,19 @@ export default function() { * Then he gets a notification message. */ describe('failed login as john in first factor', function() { - beforeEach(async function() { - this.timeout(10000); + this.timeout(10000); + + before(async function() { + this.driver = await StartDriver(); await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/") await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'bad_password'); }); + after(async function() { + await StopDriver(this.driver); + }) + it('should get a notification message', async function () { - this.timeout(10000); await VerifyNotificationDisplayed(this.driver, AUTHENTICATION_FAILED); }); }); diff --git a/test/suites/minimal/scenarii/Inactivity.ts b/test/suites/minimal/scenarii/Inactivity.ts index 1d26fe0b..36fa08bf 100644 --- a/test/suites/minimal/scenarii/Inactivity.ts +++ b/test/suites/minimal/scenarii/Inactivity.ts @@ -5,14 +5,20 @@ import { WebDriver } from "selenium-webdriver"; import VisitPageAndWaitUrlIs from "../../../helpers/behaviors/VisitPageAndWaitUrlIs"; import VisitPage from "../../../helpers/VisitPage"; import VerifyUrlIs from "../../../helpers/assertions/VerifyUrlIs"; +import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver"; export default function(this: Mocha.ISuiteCallbackContext) { this.timeout(20000); beforeEach(async function() { + this.driver = await StartDriver(); this.secret = await LoginAndRegisterTotp(this.driver, "john", true); }); + afterEach(async function() { + await StopDriver(this.driver); + }) + it("should disconnect user after inactivity period", async function() { const driver = this.driver as WebDriver; await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html"); diff --git a/test/suites/minimal/scenarii/RegisterTotp.ts b/test/suites/minimal/scenarii/RegisterTotp.ts index d65fea11..71162755 100644 --- a/test/suites/minimal/scenarii/RegisterTotp.ts +++ b/test/suites/minimal/scenarii/RegisterTotp.ts @@ -1,6 +1,7 @@ import SeleniumWebdriver, { WebDriver } from "selenium-webdriver"; import Assert from 'assert'; import LoginAndRegisterTotp from '../../../helpers/LoginAndRegisterTotp'; +import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver"; /** * Given the user logs in as john, @@ -9,9 +10,15 @@ import LoginAndRegisterTotp from '../../../helpers/LoginAndRegisterTotp'; */ export default function() { describe('successfully login as john', function() { - beforeEach('register successfully', async function() { - this.timeout(10000); + this.timeout(10000); + + beforeEach(async function() { + this.driver = await StartDriver(); await LoginAndRegisterTotp(this.driver, "john", true); + }); + + afterEach(async function() { + await StopDriver(this.driver); }) it("should see generated qrcode", async function() { diff --git a/test/suites/minimal/scenarii/ResetPassword.ts b/test/suites/minimal/scenarii/ResetPassword.ts index f95ec7b8..f2b6b95d 100644 --- a/test/suites/minimal/scenarii/ResetPassword.ts +++ b/test/suites/minimal/scenarii/ResetPassword.ts @@ -9,8 +9,17 @@ import IsSecondFactorStage from "../../../helpers/assertions/VerifyIsSecondFacto import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs'; import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed'; import VerifyUrlIs from '../../../helpers/assertions/VerifyUrlIs'; +import { StartDriver, StopDriver } from '../../../helpers/context/WithDriver'; export default function() { + beforeEach(async function() { + this.driver = await StartDriver(); + }); + + afterEach(async function() { + await StopDriver(this.driver); + }) + it("should reset password for john", async function() { await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/"); await ClickOnLink(this.driver, "Forgot password\?"); diff --git a/test/suites/minimal/scenarii/TOTPValidation.ts b/test/suites/minimal/scenarii/TOTPValidation.ts index 815711ad..9a9b2815 100644 --- a/test/suites/minimal/scenarii/TOTPValidation.ts +++ b/test/suites/minimal/scenarii/TOTPValidation.ts @@ -6,6 +6,7 @@ import { AUTHENTICATION_TOTP_FAILED } from '../../../../shared/UserMessages'; import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs'; import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed'; import VerifyUrlIs from '../../../helpers/assertions/VerifyUrlIs'; +import { StartDriver, StopDriver } from '../../../helpers/context/WithDriver'; export default function() { /** @@ -14,13 +15,21 @@ export default function() { * Then he has access to secret page. */ describe('Successfully pass second factor with TOTP', function() { - beforeEach(async function() { + before(async function() { + this.driver = await StartDriver(); const secret = await LoginAndRegisterTotp(this.driver, "john", true); if (!secret) throw new Error('No secret!'); await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html"); await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'password'); await ValidateTotp(this.driver, secret); + }); + + after(async function() { + await StopDriver(this.driver); + }); + + it("should be automatically redirected to secret page", async function() { await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html"); }); @@ -35,7 +44,8 @@ export default function() { * Then he gets a notification message. */ describe('Fail validation of second factor with TOTP', function() { - beforeEach(async function() { + before(async function() { + this.driver = await StartDriver(); await LoginAndRegisterTotp(this.driver, "john", true); const BAD_TOKEN = "125478"; @@ -44,6 +54,10 @@ export default function() { await ValidateTotp(this.driver, BAD_TOKEN); }); + after(async function() { + await StopDriver(this.driver); + }); + it("get a notification message", async function() { await VerifyNotificationDisplayed(this.driver, AUTHENTICATION_TOTP_FAILED); });