2017-10-16 22:35:34 +00:00
|
|
|
import Sinon = require("sinon");
|
|
|
|
import BluebirdPromise = require("bluebird");
|
2017-10-23 21:42:30 +00:00
|
|
|
import { ITotpHandler } from "../../src/lib/authentication/totp/ITotpHandler";
|
2017-10-16 22:35:34 +00:00
|
|
|
import { TOTPSecret } from "../../types/TOTPSecret";
|
|
|
|
|
|
|
|
export class TotpHandlerStub implements ITotpHandler {
|
|
|
|
generateStub: Sinon.SinonStub;
|
|
|
|
validateStub: Sinon.SinonStub;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.generateStub = Sinon.stub();
|
|
|
|
this.validateStub = Sinon.stub();
|
|
|
|
}
|
|
|
|
|
2017-10-23 21:42:30 +00:00
|
|
|
generate(label: string, issuer: string): TOTPSecret {
|
|
|
|
return this.generateStub(label, issuer);
|
2017-10-16 22:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
validate(token: string, secret: string): boolean {
|
|
|
|
return this.validateStub(token, secret);
|
|
|
|
}
|
|
|
|
}
|