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