authelia/server/test/mocks/RequestLoggerStub.ts
Clement Michaud 73d5253297 Disable notifiers when server uses single factor method only
Notifier is not mandatory when authentication method is single_factor for
all sub-domains since there is no registration required.
2017-10-31 07:37:15 +01:00

38 lines
1.2 KiB
TypeScript

import { IRequestLogger } from "../../src/lib/logging/IRequestLogger";
import Sinon = require("sinon");
import { RequestLogger } from "../../src/lib/logging/RequestLogger";
import Winston = require("winston");
import Express = require("express");
export class RequestLoggerStub implements IRequestLogger {
infoStub: Sinon.SinonStub;
debugStub: Sinon.SinonStub;
errorStub: Sinon.SinonStub;
private requestLogger: RequestLogger;
constructor(enableLogging?: boolean) {
this.infoStub = Sinon.stub();
this.debugStub = Sinon.stub();
this.errorStub = Sinon.stub();
if (enableLogging)
this.requestLogger = new RequestLogger(Winston);
}
info(req: Express.Request, message: string, ...args: any[]): void {
if (this.requestLogger)
this.requestLogger.info(req, message, ...args);
this.infoStub(req, message, ...args);
}
debug(req: Express.Request, message: string, ...args: any[]): void {
if (this.requestLogger)
this.requestLogger.info(req, message, ...args);
this.debugStub(req, message, ...args);
}
error(req: Express.Request, message: string, ...args: any[]): void {
if (this.requestLogger)
this.requestLogger.info(req, message, ...args);
this.errorStub(req, message, ...args);
}
}