mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Use driver methods for minimal suite.
This commit is contained in:
parent
3702d6607d
commit
29e2799021
|
@ -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);
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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\?");
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user