throw if trying to overwrite time in non-test env

This commit is contained in:
freewil 2014-04-07 04:11:03 -07:00
parent 3873e43f39
commit f53ba3822c
2 changed files with 7 additions and 11 deletions

View File

@ -120,11 +120,9 @@ totp.gen = function(key, opt) {
// Time has been overwritten. // Time has been overwritten.
if(opt._t) { if(opt._t) {
console.log('#####################################'); if(process.env.NODE_ENV != 'test') {
console.log('# NOTE: TOTP TIME VARIABLE HAS BEEN #'); throw new Error('cannot overwrite time in non-test environment!');
console.log('# OVERWRITTEN. THIS SHOULD ONLY BE #'); }
console.log('# USED FOR TEST PURPOSES. #');
console.log('#####################################');
_t = opt._t; _t = opt._t;
} }
@ -172,11 +170,9 @@ totp.verify = function(token, key, opt) {
// Time has been overwritten. // Time has been overwritten.
if(opt._t) { if(opt._t) {
console.log('#####################################'); if(process.env.NODE_ENV != 'test') {
console.log('# NOTE: TOTP TIME VARIABLE HAS BEEN #'); throw new Error('cannot overwrite time in non-test environment!');
console.log('# OVERWRITTEN. THIS SHOULD ONLY BE #'); }
console.log('# USED FOR TEST PURPOSES. #');
console.log('#####################################');
_t = opt._t; _t = opt._t;
} }

View File

@ -10,7 +10,7 @@
}, },
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "mocha" "test": "NODE_ENV=test mocha"
}, },
"engines": { "engines": {
"node": ">= v0.6.0" "node": ">= v0.6.0"