2017-05-25 13:09:29 +00:00
|
|
|
|
import sinon = require("sinon");
|
|
|
|
|
import express = require("express");
|
2017-07-19 19:06:12 +00:00
|
|
|
|
import winston = require("winston");
|
|
|
|
|
import { UserDataStoreStub } from "./storage/UserDataStoreStub";
|
2017-09-02 20:38:26 +00:00
|
|
|
|
import { VARIABLES_KEY } from "../../../../src/server/lib/ServerVariablesHandler";
|
2017-05-25 13:09:29 +00:00
|
|
|
|
|
|
|
|
|
export interface ServerVariablesMock {
|
|
|
|
|
logger: any;
|
2017-07-19 19:06:12 +00:00
|
|
|
|
ldapAuthenticator: any;
|
|
|
|
|
ldapEmailsRetriever: any;
|
|
|
|
|
ldapPasswordUpdater: any;
|
2017-05-25 13:09:29 +00:00
|
|
|
|
totpValidator: any;
|
|
|
|
|
totpGenerator: any;
|
|
|
|
|
u2f: any;
|
2017-07-19 19:06:12 +00:00
|
|
|
|
userDataStore: UserDataStoreStub;
|
2017-05-25 13:09:29 +00:00
|
|
|
|
notifier: any;
|
|
|
|
|
regulator: any;
|
|
|
|
|
config: any;
|
|
|
|
|
accessController: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-07-19 19:06:12 +00:00
|
|
|
|
export function mock(app: express.Application): ServerVariablesMock {
|
|
|
|
|
const mocks: ServerVariablesMock = {
|
|
|
|
|
accessController: sinon.stub(),
|
|
|
|
|
config: sinon.stub(),
|
2017-07-16 15:37:13 +00:00
|
|
|
|
ldapAuthenticator: sinon.stub() as any,
|
|
|
|
|
ldapEmailsRetriever: sinon.stub() as any,
|
|
|
|
|
ldapPasswordUpdater: sinon.stub() as any,
|
2017-07-19 19:06:12 +00:00
|
|
|
|
logger: winston,
|
|
|
|
|
notifier: sinon.stub(),
|
|
|
|
|
regulator: sinon.stub(),
|
|
|
|
|
totpGenerator: sinon.stub(),
|
|
|
|
|
totpValidator: sinon.stub(),
|
|
|
|
|
u2f: sinon.stub(),
|
|
|
|
|
userDataStore: new UserDataStoreStub()
|
2017-05-25 13:09:29 +00:00
|
|
|
|
};
|
|
|
|
|
app.get = sinon.stub().withArgs(VARIABLES_KEY).returns(mocks);
|
|
|
|
|
return mocks;
|
|
|
|
|
}
|