Skip to content
Permalink
Browse files

fix(test): crash if missing config token object

  • Loading branch information...
polonel committed Mar 27, 2019
1 parent c9ce050 commit ac3fe8158379add4551dea9146ded2ed51b6811d
Showing with 21 additions and 1 deletion.
  1. +11 −0 app.js
  2. +1 −1 src/passport/index.js
  3. +9 −0 test/source/installServer.js
11 app.js
@@ -122,6 +122,17 @@ function start () {
}

function launchServer (db) {
var Chance = require('chance')
var chance = new Chance()

if (!nconf.get('tokens')) {
nconf.set('tokens:secret', chance.hash() + chance.md5())
nconf.set('tokens:expires', 900)
nconf.save(function (err) {
if (err) winston.warn(err)
})
}

var ws = require('./src/webserver')
ws.init(db, function (err) {
if (err) {
@@ -91,7 +91,7 @@ module.exports = function () {
new JwtStrategy(
{
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: nconf.get('tokens').secret,
secretOrKey: nconf.get('tokens') ? nconf.get('tokens').secret : false,
ignoreExpiration: true
},
function (jwtPayload, done) {
@@ -1,3 +1,12 @@
var nconf = require('nconf')
nconf.argv().env()
nconf.overrides({
tokens: {
secret: 'TestSecretKey',
expires: 900
}
})

var is = require('../../src/webserver')

describe('installServer.js', function () {

0 comments on commit ac3fe81

Please sign in to comment.
You can’t perform that action at this time.