2019-02-14 05:04:57 +07:00
|
|
|
import { StartDriver, StopDriver } from "../../../helpers/context/WithDriver";
|
|
|
|
import LoginAs from "../../../helpers/LoginAs";
|
|
|
|
import VerifyNotificationDisplayed from "../../../helpers/assertions/VerifyNotificationDisplayed";
|
|
|
|
import VerifyIsSecondFactorStage from "../../../helpers/assertions/VerifyIsSecondFactorStage";
|
2019-04-25 04:52:08 +07:00
|
|
|
import ClearFieldById from "../../../helpers/behaviors/ClearFieldById";
|
|
|
|
import {WebDriver} from "selenium-webdriver";
|
|
|
|
|
|
|
|
async function ClearAndLoginAgain(driver: WebDriver, username: string, password: string) {
|
|
|
|
await ClearFieldById(driver, "username");
|
|
|
|
await LoginAs(driver, username, password);
|
|
|
|
}
|
2019-02-14 05:04:57 +07:00
|
|
|
|
|
|
|
export default function() {
|
|
|
|
describe('Authelia regulates authentications when a hacker is brute forcing', function() {
|
2019-04-25 04:52:08 +07:00
|
|
|
this.timeout(30000);
|
2019-02-14 06:27:43 +07:00
|
|
|
beforeEach(async function() {
|
2019-02-14 05:04:57 +07:00
|
|
|
this.driver = await StartDriver();
|
|
|
|
});
|
|
|
|
|
2019-02-14 06:27:43 +07:00
|
|
|
afterEach(async function() {
|
2019-02-14 05:04:57 +07:00
|
|
|
await StopDriver(this.driver);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return an error message when providing correct credentials the 4th time.", async function() {
|
|
|
|
await LoginAs(this.driver, "blackhat", "bad-password");
|
2019-04-25 04:52:08 +07:00
|
|
|
await VerifyNotificationDisplayed(this.driver, "Authentication failed. Check your credentials.");
|
|
|
|
await ClearAndLoginAgain(this.driver, "blackhat", "bad-password");
|
|
|
|
await VerifyNotificationDisplayed(this.driver, "Authentication failed. Check your credentials.");
|
|
|
|
await ClearAndLoginAgain(this.driver, "blackhat", "bad-password");
|
|
|
|
await VerifyNotificationDisplayed(this.driver, "Authentication failed. Check your credentials.");
|
2019-02-14 05:04:57 +07:00
|
|
|
|
|
|
|
// when providing good credentials, the hacker is regulated and see same message as previously.
|
2019-04-25 04:52:08 +07:00
|
|
|
await ClearAndLoginAgain(this.driver, "blackhat", "bad-password");
|
|
|
|
await VerifyNotificationDisplayed(this.driver, "Authentication failed. Check your credentials.");
|
2019-02-14 05:04:57 +07:00
|
|
|
|
|
|
|
// Wait the regulation ban time before retrying with correct credentials.
|
|
|
|
// It should authenticate normally.
|
2019-04-25 04:52:08 +07:00
|
|
|
await this.driver.sleep(12000);
|
|
|
|
await ClearAndLoginAgain(this.driver, "blackhat", "password");
|
2019-02-14 05:04:57 +07:00
|
|
|
await VerifyIsSecondFactorStage(this.driver);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|