import Sinon = require("sinon"); import BluebirdPromise = require("bluebird"); import { TOTPSecretDocument } from "../../../../../src/server/lib/storage/TOTPSecretDocument"; import { U2FRegistrationDocument } from "../../../../../src/server/lib/storage/U2FRegistrationDocument"; import { U2FRegistration } from "../../../../../src/types/U2FRegistration"; import { TOTPSecret } from "../../../../../src/types/TOTPSecret"; import { AuthenticationTraceDocument } from "../../../../../src/server/lib/storage/AuthenticationTraceDocument"; import { IdentityValidationDocument } from "../../../../../src/server/lib/storage/IdentityValidationDocument"; import { IUserDataStore } from "../../../../../src/server/lib/storage/IUserDataStore"; export class UserDataStoreStub implements IUserDataStore { saveU2FRegistrationStub: Sinon.SinonStub; retrieveU2FRegistrationStub: Sinon.SinonStub; saveAuthenticationTraceStub: Sinon.SinonStub; retrieveLatestAuthenticationTracesStub: Sinon.SinonStub; produceIdentityValidationTokenStub: Sinon.SinonStub; consumeIdentityValidationTokenStub: Sinon.SinonStub; saveTOTPSecretStub: Sinon.SinonStub; retrieveTOTPSecretStub: Sinon.SinonStub; constructor() { this.saveU2FRegistrationStub = Sinon.stub(); this.retrieveU2FRegistrationStub = Sinon.stub(); this.saveAuthenticationTraceStub = Sinon.stub(); this.retrieveLatestAuthenticationTracesStub = Sinon.stub(); this.produceIdentityValidationTokenStub = Sinon.stub(); this.consumeIdentityValidationTokenStub = Sinon.stub(); this.saveTOTPSecretStub = Sinon.stub(); this.retrieveTOTPSecretStub = Sinon.stub(); } saveU2FRegistration(userId: string, appId: string, registration: U2FRegistration): BluebirdPromise { return this.saveU2FRegistrationStub(userId, appId, registration); } retrieveU2FRegistration(userId: string, appId: string): BluebirdPromise { return this.retrieveU2FRegistrationStub(userId, appId); } saveAuthenticationTrace(userId: string, isAuthenticationSuccessful: boolean): BluebirdPromise { return this.saveAuthenticationTraceStub(userId, isAuthenticationSuccessful); } retrieveLatestAuthenticationTraces(userId: string, isAuthenticationSuccessful: boolean, count: number): BluebirdPromise { return this.retrieveLatestAuthenticationTracesStub(userId, isAuthenticationSuccessful, count); } produceIdentityValidationToken(userId: string, token: string, challenge: string, maxAge: number): BluebirdPromise { return this.produceIdentityValidationTokenStub(userId, token, challenge, maxAge); } consumeIdentityValidationToken(token: string, challenge: string): BluebirdPromise { return this.consumeIdentityValidationTokenStub(token, challenge); } saveTOTPSecret(userId: string, secret: TOTPSecret): BluebirdPromise { return this.saveTOTPSecretStub(userId, secret); } retrieveTOTPSecret(userId: string): BluebirdPromise { return this.retrieveTOTPSecretStub(userId); } }