2017-10-07 16:37:08 +00:00
|
|
|
import { AuthenticationMethodCalculator } from "../src/lib/AuthenticationMethodCalculator";
|
|
|
|
import { AuthenticationMethodsConfiguration } from "../src/lib/configuration/Configuration";
|
|
|
|
import Assert = require("assert");
|
|
|
|
|
|
|
|
describe("test authentication method calculator", function() {
|
|
|
|
it("should return default method when sub domain not overriden", function() {
|
|
|
|
const options1: AuthenticationMethodsConfiguration = {
|
|
|
|
default_method: "two_factor",
|
|
|
|
per_subdomain_methods: {}
|
|
|
|
};
|
|
|
|
const options2: AuthenticationMethodsConfiguration = {
|
2017-10-18 22:33:02 +00:00
|
|
|
default_method: "single_factor",
|
2017-10-07 16:37:08 +00:00
|
|
|
per_subdomain_methods: {}
|
|
|
|
};
|
|
|
|
const calculator1 = new AuthenticationMethodCalculator(options1);
|
|
|
|
const calculator2 = new AuthenticationMethodCalculator(options2);
|
|
|
|
Assert.equal(calculator1.compute("www.example.com"), "two_factor");
|
2017-10-18 22:33:02 +00:00
|
|
|
Assert.equal(calculator2.compute("www.example.com"), "single_factor");
|
2017-10-07 16:37:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should return overridden method when sub domain method is defined", function() {
|
|
|
|
const options1: AuthenticationMethodsConfiguration = {
|
|
|
|
default_method: "two_factor",
|
|
|
|
per_subdomain_methods: {
|
2017-10-18 22:33:02 +00:00
|
|
|
"www.example.com": "single_factor"
|
2017-10-07 16:37:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
const calculator1 = new AuthenticationMethodCalculator(options1);
|
2017-10-18 22:33:02 +00:00
|
|
|
Assert.equal(calculator1.compute("www.example.com"), "single_factor");
|
2017-10-07 16:37:08 +00:00
|
|
|
});
|
2017-10-18 22:33:02 +00:00
|
|
|
});
|