authelia/test/minimal-config/fail_totp.ts

40 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-08-09 20:24:02 +00:00
require("chromedriver");
import WithDriver from '../helpers/with-driver';
import FillLoginPageWithUserAndPasswordAndClick from '../helpers/fill-login-page-and-click';
import VisitPage from '../helpers/visit-page';
import ValidateTotp from '../helpers/validate-totp';
import LoginAndRegisterTotp from '../helpers/login-and-register-totp';
import seeNotification from "../helpers/see-notification";
import {AUTHENTICATION_TOTP_FAILED} from '../../shared/UserMessages';
2018-08-09 20:24:02 +00:00
/**
* Given john has registered a TOTP secret,
* When he fails the TOTP challenge,
* Then he gets a notification message.
*/
describe('Fail TOTP challenge', function() {
this.timeout(10000);
WithDriver();
describe('successfully login as john', function() {
before(function() {
return LoginAndRegisterTotp(this.driver, "john", true);
2018-08-09 20:24:02 +00:00
});
describe('fail second factor', function() {
before(function() {
const BAD_TOKEN = "125478";
const driver = this.driver;
return VisitPage(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html")
.then(() => FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password'))
.then(() => ValidateTotp(driver, BAD_TOKEN));
});
it("get a notification message", function() {
return seeNotification(this.driver, "error", AUTHENTICATION_TOTP_FAILED);
2018-08-09 20:24:02 +00:00
});
});
});
});