mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
b9fa786df6
This refactoring aims to ease testability and clean up a lot of soft touchy typings in test code. This is the first step of this refactoring introducing the concept and implementing missing interfaces and stubs. At the end of the day, ServerVariablesHandler should completely disappear and every variable should be injected in the endpoint handler builder itself.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import Sinon = require("sinon");
|
|
import BluebirdPromise = require("bluebird");
|
|
import U2f = require("u2f");
|
|
import { IU2fHandler } from "../../src/lib/authentication/u2f/IU2fHandler";
|
|
|
|
|
|
export class U2fHandlerStub implements IU2fHandler {
|
|
requestStub: Sinon.SinonStub;
|
|
checkRegistrationStub: Sinon.SinonStub;
|
|
checkSignatureStub: Sinon.SinonStub;
|
|
|
|
constructor() {
|
|
this.requestStub = Sinon.stub();
|
|
this.checkRegistrationStub = Sinon.stub();
|
|
this.checkSignatureStub = Sinon.stub();
|
|
}
|
|
|
|
request(appId: string, keyHandle?: string): U2f.Request {
|
|
return this.requestStub(appId, keyHandle);
|
|
}
|
|
|
|
checkRegistration(registrationRequest: U2f.Request, registrationResponse: U2f.RegistrationData)
|
|
: U2f.RegistrationResult | U2f.Error {
|
|
return this.checkRegistrationStub(registrationRequest, registrationResponse);
|
|
}
|
|
|
|
checkSignature(signatureRequest: U2f.Request, signatureResponse: U2f.SignatureData, publicKey: string)
|
|
: U2f.SignatureResult | U2f.Error {
|
|
return this.checkSignatureStub(signatureRequest, signatureResponse, publicKey);
|
|
}
|
|
} |