2017-10-09 21:13:57 +00:00
|
|
|
import { AuthenticationMethodsAdapter } from "../../../src/lib/configuration/adapters/AuthenticationMethodsAdapter";
|
|
|
|
import Assert = require("assert");
|
|
|
|
|
|
|
|
describe("test authentication methods configuration adapter", function () {
|
|
|
|
describe("no authentication methods defined", function () {
|
|
|
|
it("should adapt a configuration when no authentication methods config is defined", function () {
|
|
|
|
const userConfiguration: any = undefined;
|
|
|
|
|
|
|
|
const appConfiguration = AuthenticationMethodsAdapter.adapt(userConfiguration);
|
|
|
|
Assert.deepStrictEqual(appConfiguration, {
|
|
|
|
default_method: "two_factor",
|
|
|
|
per_subdomain_methods: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("partial authentication methods config", function() {
|
|
|
|
it("should adapt a configuration when default_method is not defined", function () {
|
|
|
|
const userConfiguration: any = {
|
|
|
|
per_subdomain_methods: {
|
2017-10-18 22:33:02 +00:00
|
|
|
"example.com": "single_factor"
|
2017-10-09 21:13:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const appConfiguration = AuthenticationMethodsAdapter.adapt(userConfiguration);
|
|
|
|
Assert.deepStrictEqual(appConfiguration, {
|
|
|
|
default_method: "two_factor",
|
|
|
|
per_subdomain_methods: {
|
2017-10-18 22:33:02 +00:00
|
|
|
"example.com": "single_factor"
|
2017-10-09 21:13:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should adapt a configuration when per_subdomain_methods is not defined", function () {
|
|
|
|
const userConfiguration: any = {
|
2017-10-18 22:33:02 +00:00
|
|
|
default_method: "single_factor"
|
2017-10-09 21:13:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const appConfiguration = AuthenticationMethodsAdapter.adapt(userConfiguration);
|
|
|
|
Assert.deepStrictEqual(appConfiguration, {
|
2017-10-18 22:33:02 +00:00
|
|
|
default_method: "single_factor",
|
2017-10-09 21:13:57 +00:00
|
|
|
per_subdomain_methods: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should adapt a configuration when per_subdomain_methods has wrong type", function () {
|
|
|
|
const userConfiguration: any = {
|
2017-10-18 22:33:02 +00:00
|
|
|
default_method: "single_factor",
|
2017-10-09 21:13:57 +00:00
|
|
|
per_subdomain_methods: []
|
|
|
|
};
|
|
|
|
|
|
|
|
const appConfiguration = AuthenticationMethodsAdapter.adapt(userConfiguration);
|
|
|
|
Assert.deepStrictEqual(appConfiguration, {
|
2017-10-18 22:33:02 +00:00
|
|
|
default_method: "single_factor",
|
2017-10-09 21:13:57 +00:00
|
|
|
per_subdomain_methods: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-10-18 22:33:02 +00:00
|
|
|
});
|