Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it ('should resolve if authentication has been performed', function() {
var subscribeSpy = sinon.spy();
var host = {
_getFayeClient: sinon.stub().returns({
subscribe: subscribeSpy
}),
_getAuth: sinon.stub().returns({
isAuthenticated: sinon.stub().returns(Promise.resolve())
})
};
var options = {
timestamp: 1435054283,
expires_in: 21600,
channel: "/conversation/2256621",
signature: "7d2018df16bd7686063483c8960124bc0a1bb0e2"
};
var handler = new Function();
var subscription = pushLib.push.call(host, options).subscribe(handler);
subscription.then(function() {
// Assert that the Faye client is properly subscribed to
it ('should reject if authentication has not been performed', function(done) {
var host = {
_getAuth: sinon.stub().returns({
isAuthenticated: sinon.stub().returns(Promise.reject())
})
};
var options = {
timestamp: 1435054283,
expires_in: 21600,
channel: "/conversation/2256621",
signature: "7d2018df16bd7686063483c8960124bc0a1bb0e2"
};
var subscription = pushLib.push.call(host, options).subscribe(new Function());
subscription.then(function(){
// Should not be called
expect('Authentication should not pass').toBe(false);
}).catch(function(err) {
function updateRuleFiles(cb: Function) {
const ruleDir = 'src/rules/';
const allFiles = fs.readdirSync(ruleDir).filter(
file => fs.lstatSync(path.join(ruleDir, file)).isFile()
);
const ruleNames = allFiles
.filter(name => /\.ts$/.test(name))
.map(name => name.substr(0, name.length - 7));
const allPromises: Promise[] = [];
ruleNames.forEach((name) => {
allPromises.push(updateRuleFile(name, ruleTSMap[name]));
});
// Only do the callback when all the promises have been resolved.
Promise.all(allPromises).then(() => {
console.log('[DONE] processing rule files ...');
cb();
});
}
DebugTarget.prototype.sendCommand = function(command, args) {
// Construct packet object.
var packet = {
'seq': ++this.nextTargetSeqId_,
'type': 'request',
'command': command
};
if (args) {
packet['arguments'] = args;
}
// Stash promise.
var promise = new Promise((function(resolve, reject) {
this.pendingTargetPromises_[packet['seq']] = {
resolve: resolve,
reject: reject
};
}).bind(this));
// Send the data.
var packetString = JSON.stringify(packet);
var packetLength = packetString.length;
this.targetSocket_.write(
'Content-Length: ' + packetLength + '\r\n\r\n' +
packetString);
if (this.argv_['log-network']) {
console.log('[->V8]', packetString);
}
* specific language governing permissions and limitations
* under the License.
*/
import {remote} from 'electron';
import {inspect} from 'util';
import log from 'electron-log';
import promise from 'es6-promise';
import fetch from 'isomorphic-fetch';
import {IoTHubApi, FlashAIrScript} from '../../common/config';
import {IoTHubApiConst} from '../../common/const';
import {AppEvent} from '../../common/event';
import {basename} from '../../common/util';
promise.polyfill();
const {dialog} = remote;
import fs from 'fs';
import path from 'path';
export class IoTHubAction {
constructor(dispatcher) {
this.dispatcher = dispatcher;
}
handleHttpStatus(response) {
if ((response.status === 200) // Status OK
|| (response.status === 201) // Created
|| (response.status === 204)) { // No Conten
return Promise.resolve(response);
}
console.log(inspect(response, {
showHidden: false,
return function (request) {
var params = v8capnp.toJsParams(request, Capability);
v8capnp.releaseParams(request);
Promise.cast(method.apply(self, params)).then(function (results) {
if (typeof results !== "object") {
if (results === undefined) {
results = [];
} else {
// Wrap single primitive return value in an array.
results = [results];
}
}
v8capnp.fromJs(v8capnp.getResults(request), results, LocalCapWrapper);
v8capnp.return_(request);
}).catch(function (error) {
v8capnp.throw_(request, error);
}).catch(function (error) {
console.error("Cap'n Proto v8 bug when returning from incoming method call:", error);
});
}
async login(user: User): P {
// need to disable angular wait before check for current url because we're being redirected outside of angular
browser.waitForAngularEnabled(false);
this.goToUrl(AppPage.baseurl);
// wait either for login page or loaded ipaas app
await P.race([
browser.wait(ExpectedConditions.presenceOf(this.rootElement), 1000, 'ipaas root element - assuming we are already logged in'),
browser.wait(ExpectedConditions.presenceOf(element(by.css('input'))), 1000, 'Some input field - assuming we are on login page'),
]);
const url = await this.currentUrl();
if (contains(url, 'github')) {
// we need to login on github
await new GithubLogin().login(user);
} else if (contains(url, browser.baseUrl)) {
// pass - we're already logged in
} else {
return P.reject(`Unsupported login page ${url}`);
}
browser.waitForAngularEnabled(true);
return this.goToUrl(AppPage.baseurl);
'use strict';
var core = require('../core');
var microtask = require('../microtask');
var browserPatch = require('../patch/browser');
var es6Promise = require('es6-promise');
if (global.Zone) {
console.warn('Zone already exported on window the object!');
}
global.Zone = microtask.addMicrotaskSupport(core.Zone);
global.zone = new global.Zone();
// Monkey patch the Promise implementation to add support for microtasks
global.Promise = es6Promise.Promise;
browserPatch.apply();
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../core":2,"../microtask":4,"../patch/browser":5,"es6-promise":17}],2:[function(require,module,exports){
'use strict';
var core = require('../core');
var microtask = require('../microtask');
var browserPatch = require('../patch/browser');
var es6Promise = require('es6-promise');
if (global.Zone) {
console.warn('Zone already exported on window the object!');
}
global.Zone = microtask.addMicrotaskSupport(core.Zone);
global.zone = new global.Zone();
// Monkey patch the Promise implementation to add support for microtasks
global.Promise = es6Promise.Promise;
browserPatch.apply();
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../core":2,"../microtask":4,"../patch/browser":5,"es6-promise":17}],2:[function(require,module,exports){
// tslint:disable-next-line:no-var-requires
require("es6-promise").polyfill();
import "@/assets/css/style.css";
import "nprogress/nprogress.css";
import Vue from "vue";
import { sync } from "vuex-router-sync";
// @ts-ignore
import App from "./App.vue";
import router from "./router";
import store from "./store";
import directives from "./directives";
import mixins from "./mixins";
// @ts-ignore
import VTooltip from "v-tooltip";
// @ts-ignore
import VueGoodTablePlugin from "vue-good-table";