2017-09-24 21:19:03 +00:00
|
|
|
import Sinon = require("sinon");
|
2017-05-25 13:09:29 +00:00
|
|
|
import express = require("express");
|
2017-10-07 22:46:57 +00:00
|
|
|
import { RequestLoggerStub } from "./RequestLoggerStub";
|
2017-07-19 19:06:12 +00:00
|
|
|
import { UserDataStoreStub } from "./storage/UserDataStoreStub";
|
2017-10-07 16:37:08 +00:00
|
|
|
import { AuthenticationMethodCalculator } from "../../src/lib/AuthenticationMethodCalculator";
|
2017-10-06 22:09:42 +00:00
|
|
|
import { VARIABLES_KEY } from "../../src/lib/ServerVariablesHandler";
|
2017-05-25 13:09:29 +00:00
|
|
|
|
|
|
|
export interface ServerVariablesMock {
|
2017-09-24 21:19:03 +00:00
|
|
|
logger: any;
|
|
|
|
ldapAuthenticator: any;
|
|
|
|
ldapEmailsRetriever: any;
|
|
|
|
ldapPasswordUpdater: any;
|
|
|
|
totpValidator: any;
|
|
|
|
totpGenerator: any;
|
|
|
|
u2f: any;
|
|
|
|
userDataStore: UserDataStoreStub;
|
|
|
|
notifier: any;
|
|
|
|
regulator: any;
|
|
|
|
config: any;
|
|
|
|
accessController: any;
|
2017-10-07 16:37:08 +00:00
|
|
|
authenticationMethodsCalculator: any;
|
2017-05-25 13:09:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-19 19:06:12 +00:00
|
|
|
export function mock(app: express.Application): ServerVariablesMock {
|
2017-09-24 21:19:03 +00:00
|
|
|
const mocks: ServerVariablesMock = {
|
|
|
|
accessController: Sinon.stub(),
|
|
|
|
config: Sinon.stub(),
|
|
|
|
ldapAuthenticator: Sinon.stub() as any,
|
|
|
|
ldapEmailsRetriever: Sinon.stub() as any,
|
|
|
|
ldapPasswordUpdater: Sinon.stub() as any,
|
2017-10-07 22:46:57 +00:00
|
|
|
logger: new RequestLoggerStub(),
|
2017-09-24 21:19:03 +00:00
|
|
|
notifier: Sinon.stub(),
|
|
|
|
regulator: Sinon.stub(),
|
|
|
|
totpGenerator: Sinon.stub(),
|
|
|
|
totpValidator: Sinon.stub(),
|
|
|
|
u2f: Sinon.stub(),
|
2017-10-07 16:37:08 +00:00
|
|
|
userDataStore: new UserDataStoreStub(),
|
|
|
|
authenticationMethodsCalculator: new AuthenticationMethodCalculator({
|
|
|
|
default_method: "two_factor",
|
|
|
|
per_subdomain_methods: {}
|
|
|
|
})
|
2017-09-24 21:19:03 +00:00
|
|
|
};
|
|
|
|
app.get = Sinon.stub().withArgs(VARIABLES_KEY).returns(mocks);
|
|
|
|
return mocks;
|
2017-05-25 13:09:29 +00:00
|
|
|
}
|