Skip to content

Commit

Permalink
[test] Add tests for deprecated initial_time and length
Browse files Browse the repository at this point in the history
  • Loading branch information
markbao committed Jan 25, 2016
1 parent 22d845a commit 8a922e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/hotp_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ describe('HOTP Counter-Based Algorithm Test', function () {
});
});

// Backwards compatibility - deprecated
describe("digits override with secret = '12345678901234567890' at counter 4 and length = 8", function () {
it('should return correct one-time password', function () {
var topic = speakeasy.hotp({secret: '12345678901234567890', counter: 4, length: 8});
assert.equal(topic, '40338314');
});
});

describe("hexadecimal encoding with secret = '3132333435363738393031323334353637383930' as hexadecimal at counter 4", function () {
it('should return correct one-time password', function () {
var topic = speakeasy.hotp({secret: '3132333435363738393031323334353637383930', encoding: 'hex', counter: 4});
Expand Down
8 changes: 8 additions & 0 deletions test/totp_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ describe('TOTP Time-Based Algorithm Test', function () {
});
});

// Backwards compatibility - deprecated
describe("initial time with secret = '12345678901234567890' at time = 1111111109 and initial_time = 1111111100", function () {
it('should return correct one-time password', function () {
var topic = speakeasy.totp({secret: '12345678901234567890', time: 1111111109, initial_time: 1111111100});
assert.equal(topic, '755224');
});
});

describe("base32 encoding with secret = '1234567890' at time = 1111111109", function () {
it('should return correct one-time password', function () {
var topic = speakeasy.totp({secret: '12345678901234567890', time: 1111111109});
Expand Down

0 comments on commit 8a922e6

Please sign in to comment.