Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// jscs:disable maximumLineLength
'use strict';
var chai = require('chai');
var _ = require('lodash');
var restify = require('restify-clients');
var demoServer = require('../example/demo');
var assert = chai.assert;
var client = restify.createJsonClient({
url: 'http://localhost:3003'
});
var stringClient = restify.createStringClient({
url: 'http://localhost:3003'
});
// star tests
describe('Integration tests using the demo app', function() {
before(function(done) {
demoServer.listen(3003, done);
});
after(function(done) {
client.close();
stringClient.close();
demoServer.close(done);
function create(model) {
assert.string(model.host, 'model.host');
assert.optionalNumber(model.port, 'model.port');
assert.optionalObject(model.headers, 'model.headers');
var remoteHost = new Urijs(model.host)
.port(model.port || 80)
.protocol(model.secure ? 'https' : 'http')
.toString();
return restify.createJsonClient({
url: remoteHost,
// TODO: this doesn't seem to log anything?!
log: logHelpers.child({ component: 'jsonClient' })
});
}
it('should not accept unsupported content encoding', function (done) {
SERVER.use(restify.plugins.bodyParser());
CLIENT = restifyClients.createJsonClient({
url: 'http://127.0.0.1:' + PORT,
retry: false,
headers: {
'content-encoding': 'unsupported'
}
});
SERVER.post('/compressed', function (req, res, next) {
assert.equal(req.body.apple, 'red');
res.send();
next();
});
CLIENT.post('/compressed', {
apple: 'red'
}, function (err, _, res) {
SERVER.listen(0, '127.0.0.1', function () {
PORT = SERVER.address().port;
CLIENT = restifyClients.createJsonClient({
url: 'http://127.0.0.1:' + PORT,
dtrace: helper.dtrace,
retry: false
});
done();
});
});
function createClient() {
client = restify.createJsonClient({
url: 'http://localhost:3000',
version: '*',
headers: {
connection: 'close'
}
});
}
constructor(context) {
this._context = context
this._pivotalTrackerClient = clients.createJsonClient(common.globals.pivotalBaseUrl)
const projectId = context.workspaceState.get(common.globals.projectID)
this._baseApiPath = `${common.globals.pivotalApiPrefix}/projects/${projectId}`
this._token = context.globalState.get(common.globals.APItoken)
}
constructor(apiKey, apiSecret) {
this._apiKey = apiKey
this._apiSecret = apiSecret
this.client = clients.createJsonClient({
url: 'https://api.kucoin.com'
})
this.path_prefix = '/v1'
}
function createClient() {
client = restify.createJsonClient({
url: 'http://localhost:3000',
version: '*',
headers: {
connection: 'close'
}
});
}
//previous state store
if (self._config.trackState) {
self._prevState = [];
}
//logger
if (self._config.log !== undefined) {
try {
self._log = self._config.log.child({'module': 'MMcontrol'});
} catch (exception) {
throw new TypeError('passed log is not a bunyan logger');
}
}
//JSON client
self.client = restify.createJsonClient({
url: self._config.url,
userAgent: self._config.userAgent
});
//EventEmitter
EventEmitter.call(self);
}