mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
d8ff186303
Client and server now have their own tsconfig so that the transpilation is only done on the part that is being modified. It also allows faster transpilation since tests are now excluded from tsconfig. They are compiled by ts-node during unit tests execution.
31 lines
827 B
TypeScript
31 lines
827 B
TypeScript
|
|
import { TOTPValidator } from "../src/lib/TOTPValidator";
|
|
import sinon = require("sinon");
|
|
import Promise = require("bluebird");
|
|
import SpeakeasyMock = require("./mocks/speakeasy");
|
|
|
|
describe("test TOTP validation", function() {
|
|
let totpValidator: TOTPValidator;
|
|
|
|
beforeEach(() => {
|
|
SpeakeasyMock.totp.returns("token");
|
|
totpValidator = new TOTPValidator(SpeakeasyMock as any);
|
|
});
|
|
|
|
it("should validate the TOTP token", function() {
|
|
const totp_secret = "NBD2ZV64R9UV1O7K";
|
|
const token = "token";
|
|
return totpValidator.validate(token, totp_secret);
|
|
});
|
|
|
|
it("should not validate a wrong TOTP token", function(done) {
|
|
const totp_secret = "NBD2ZV64R9UV1O7K";
|
|
const token = "wrong token";
|
|
totpValidator.validate(token, totp_secret)
|
|
.catch(function() {
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|