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