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