2017-07-20 02:06:12 +07:00
|
|
|
import Sinon = require("sinon");
|
|
|
|
import BluebirdPromise = require("bluebird");
|
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
import { TOTPSecretDocument } from "../../../src/lib/storage/TOTPSecretDocument";
|
|
|
|
import { U2FRegistrationDocument } from "../../../src/lib/storage/U2FRegistrationDocument";
|
|
|
|
import { U2FRegistration } from "../../../types/U2FRegistration";
|
|
|
|
import { TOTPSecret } from "../../../types/TOTPSecret";
|
|
|
|
import { AuthenticationTraceDocument } from "../../../src/lib/storage/AuthenticationTraceDocument";
|
|
|
|
import { IdentityValidationDocument } from "../../../src/lib/storage/IdentityValidationDocument";
|
2017-07-20 02:06:12 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
import { IUserDataStore } from "../../../src/lib/storage/IUserDataStore";
|
2017-07-20 02:06:12 +07:00
|
|
|
|
|
|
|
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<void> {
|
|
|
|
return this.saveU2FRegistrationStub(userId, appId, registration);
|
|
|
|
}
|
|
|
|
|
|
|
|
retrieveU2FRegistration(userId: string, appId: string): BluebirdPromise<U2FRegistrationDocument> {
|
|
|
|
return this.retrieveU2FRegistrationStub(userId, appId);
|
|
|
|
}
|
|
|
|
|
|
|
|
saveAuthenticationTrace(userId: string, isAuthenticationSuccessful: boolean): BluebirdPromise<void> {
|
|
|
|
return this.saveAuthenticationTraceStub(userId, isAuthenticationSuccessful);
|
|
|
|
}
|
|
|
|
|
2017-09-03 06:25:43 +07:00
|
|
|
retrieveLatestAuthenticationTraces(userId: string, count: number): BluebirdPromise<AuthenticationTraceDocument[]> {
|
|
|
|
return this.retrieveLatestAuthenticationTracesStub(userId, count);
|
2017-07-20 02:06:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
produceIdentityValidationToken(userId: string, token: string, challenge: string, maxAge: number): BluebirdPromise<any> {
|
|
|
|
return this.produceIdentityValidationTokenStub(userId, token, challenge, maxAge);
|
|
|
|
}
|
|
|
|
|
|
|
|
consumeIdentityValidationToken(token: string, challenge: string): BluebirdPromise<IdentityValidationDocument> {
|
|
|
|
return this.consumeIdentityValidationTokenStub(token, challenge);
|
|
|
|
}
|
|
|
|
|
|
|
|
saveTOTPSecret(userId: string, secret: TOTPSecret): BluebirdPromise<void> {
|
|
|
|
return this.saveTOTPSecretStub(userId, secret);
|
|
|
|
}
|
|
|
|
|
|
|
|
retrieveTOTPSecret(userId: string): BluebirdPromise<TOTPSecretDocument> {
|
|
|
|
return this.retrieveTOTPSecretStub(userId);
|
|
|
|
}
|
|
|
|
}
|