2017-09-25 04:19:03 +07:00
|
|
|
import Sinon = require("sinon");
|
2017-05-25 20:09:29 +07:00
|
|
|
import express = require("express");
|
2017-07-20 02:06:12 +07:00
|
|
|
import winston = require("winston");
|
|
|
|
import { UserDataStoreStub } from "./storage/UserDataStoreStub";
|
2017-10-07 05:09:42 +07:00
|
|
|
import { VARIABLES_KEY } from "../../src/lib/ServerVariablesHandler";
|
2017-05-25 20:09:29 +07:00
|
|
|
|
|
|
|
export interface ServerVariablesMock {
|
2017-09-25 04:19:03 +07: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-05-25 20:09:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-20 02:06:12 +07:00
|
|
|
export function mock(app: express.Application): ServerVariablesMock {
|
2017-09-25 04:19:03 +07: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,
|
|
|
|
logger: winston,
|
|
|
|
notifier: Sinon.stub(),
|
|
|
|
regulator: Sinon.stub(),
|
|
|
|
totpGenerator: Sinon.stub(),
|
|
|
|
totpValidator: Sinon.stub(),
|
|
|
|
u2f: Sinon.stub(),
|
|
|
|
userDataStore: new UserDataStoreStub()
|
|
|
|
};
|
|
|
|
app.get = Sinon.stub().withArgs(VARIABLES_KEY).returns(mocks);
|
|
|
|
return mocks;
|
2017-05-25 20:09:29 +07:00
|
|
|
}
|