Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var assert = require('assert')
var mockery = require('mockery')
var log = require('loglevel')
log.disableAll()
var param
var request = function (req) {
param = req
}
request.post = function (req) {
param = req
}
describe('Slackbot', function(){
before(function() {
mockery.enable({useCleanCache: true}); // Enable mockery at the start of your test suite
mockery.registerMock('request', request);
mockery.registerAllowables(['loglevel', 'events', '../../lib/slackbot.js', 'util']);
slackbot = require('../../lib/slackbot.js')
})
getLogger : function (name) {
// Substitute global constants configured at compile time
// cf. webpack.config.js
// FIXME howtodo !? DefineWebpackPlugin ? EnvironmentWebpackPlugin ?
("__PRODUCTION__".match(/true/))
? Log.disableAll() : Log.enableAll();
var logname = name || "default";
return Log.getLogger(logname);
}
};
"log-level": function(level) {
var hotCtx = require.context("webpack/hot", false, /^\.\/log$/);
if(hotCtx.keys().length > 0) {
hotCtx("./log").setLogLevel(level);
}
switch(level) {
case INFO:
case ERROR:
log.setLevel(level);
break;
case WARNING:
log.setLevel("warn"); // loglevel's warning name is different from webpack's
break;
case NONE:
log.disableAll();
break;
default:
log.error("[WDS] Unknown clientLogLevel '" + level + "'");
}
},
"overlay": function(overlay) {
logLevel = 'debug'
break
case 'development':
torusUrl = 'https://localhost:3000'
logLevel = 'debug'
break
default:
torusUrl = 'https://app.tor.us/v0.2.11'
logLevel = 'error'
break
}
this.torusUrl = torusUrl
this.enabledVerifiers = { ...defaultVerifiers, ...enabledVerifiers }
log.setDefaultLevel(logLevel)
if (enableLogging) log.enableAll()
else log.disableAll()
this.torusButtonVisibility = showTorusButton
this._createWidget(torusUrl)
const attachIFrame = () => {
window.document.body.appendChild(this.torusIframe)
}
if (buildEnv !== 'testing' && buildEnv !== 'development') {
// hacky solution to check for iframe integrity
const fetchUrl = torusUrl + '/popup'
fetch(fetchUrl, { cache: 'reload' })
.then(resp => {
if (resp.headers.get('Cache-Control') !== expectedCacheControlHeader) {
throw new Error('Unexpected Cache-Control headers, got ' + resp.headers.get('Cache-Control'))
}
return resp.text()
})
.then(response => {
'(logging temporarily disabled to hide exceptions)', function() {
log.disableAll();
const split = tokens.hs256.token.split('.');
const token = `${split[0]}.${split[1]}`;
const token2 = token + '.';
const promises = [
jwt.verify(token, tokens.hs256.secret),
jwt.verify(token2, tokens.hs256.secret),
jwt.verify(tokens.hs256.token, tokens.hs256.secret + 'sdfasdf'),
jwt.verify(tokens.hs256.token, 'sdfsdf' + tokens.hs256.secret),
jwt.verify(tokens.hs256.token, 'sdfsdf'),
jwt.verify(tokens.rs256.token, tokens.rs256.publicKey.replace('a','b')),
jwt.verify(tokens.es256.token, tokens.es256.publicKey.replace('a','b')),
jwt.verify(tokens.ps256.token, tokens.ps256.publicKey.replace('a','b'))
];
var assert = require('assert')
var CallManager = require('../../lib/call_manager.js')
var twilio = require('twilio')
var log = require('loglevel')
log.disableAll()
var args = null
var cb_arg = {}
var client = {
makeCall: function (options, cb) {
args = options
cb(null, cb_arg)
},
incomingPhoneNumbers: { list: function (cb) {
cb(null, {incoming_phone_numbers: [{phone_number: 1234}]})
}}
}
var failing = {
makeCall: function (options, cb) {
cb('Error')
var assert = require('assert')
var mockery = require('mockery')
var async = require('async')
var log = require('loglevel')
log.disableAll()
var location
var cbs = {
available: [],
failed: []
}
var client = {
incomingPhoneNumbers: { list: function () {}}
}
var ret = {
start: function () {
},
transcript: 'Sample',
on: function (id, cb) {
export const updateLogLevel = () => {
const isDebugMode = getSettings("isDebugMode");
if (isDebugMode) log.enableAll();
else log.disableAll();
};
level : function ( lvl ) {
if ( lvl.toLowerCase() === "none" ) {
log.disableAll();
} else {
log.setLevel( lvl );
}
},
/**