authelia/test/helpers/scenarii/SingleFactorAuthentication.ts
Clement Michaud 76fa325f08 [BREAKING] Create a suite for kubernetes tests.
Authelia client uses hash router instead of browser router in order to work
with Kubernetes nginx-ingress-controller. This is also better for users having
old browsers.

This commit is breaking because it requires to change the configuration of the
proxy to include the # in the URL of the login portal.
2019-03-16 00:13:27 +01:00

39 lines
1.6 KiB
TypeScript

import Logout from "../Logout";
import { StartDriver, StopDriver } from "../context/WithDriver";
import LoginOneFactor from "../behaviors/LoginOneFactor";
import VerifySecretObserved from "../assertions/VerifySecretObserved";
import VisitPage from "../VisitPage";
import VerifyIsSecondFactorStage from "../assertions/VerifyIsSecondFactorStage";
import VerifyUrlContains from "../assertions/VerifyUrlContains";
/*
* Those tests are related to single factor protected resources.
*/
export default function(timeout: number = 5000) {
return function() {
beforeEach(async function() {
this.driver = await StartDriver();
});
afterEach(async function() {
await Logout(this.driver);
await StopDriver(this.driver);
});
it("should redirect user after first stage", async function() {
await LoginOneFactor(this.driver, "john", "password", "https://singlefactor.example.com:8080/secret.html", timeout);
await VerifySecretObserved(this.driver, timeout);
});
it("should redirect to portal if not enough authorized", async function() {
await LoginOneFactor(this.driver, "john", "password", "https://singlefactor.example.com:8080/secret.html", timeout);
await VisitPage(this.driver, "https://admin.example.com:8080/secret.html");
// the url should be the one from the portal.
await VerifyUrlContains(this.driver, "https://login.example.com:8080/#/?rd=https://admin.example.com:8080", timeout);
// And the user should end up on the second factor page.
await VerifyIsSecondFactorStage(this.driver, timeout);
});
}
}