Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canduit

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canduit - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

8

package.json
{
"name": "canduit",
"version": "1.1.0",
"version": "1.1.1",
"description": "Node.js Phabricator Conduit API client",

@@ -31,8 +31,8 @@ "main": "canduit.js",

"getport": "^0.1.0",
"istanbul": "^0.3.2",
"istanbul": "^0.3.20",
"jshint": "^2.5.6",
"run-parallel": "^1.0.0",
"tape": "^3.0.0",
"tmp": "0.0.24"
"tape": "^4.2.0",
"tmp": "^0.0.27"
}
}

@@ -1,2 +0,2 @@

# canduit [![Build status](https://travis-ci.org/uber/canduit.png?branch=master)](https://travis-ci.org/uber/canduit)
# canduit [![Build status](https://travis-ci.org/uber/canduit.png?branch=master)](https://travis-ci.org/uber/canduit) [![bitHound Score](https://www.bithound.io/github/uber/canduit/badges/score.svg)](https://www.bithound.io/github/uber/canduit)

@@ -3,0 +3,0 @@ Node.js Phabricator Conduit API client.

@@ -10,75 +10,79 @@ var fs = require('fs');

function Fixtures(test) {
test('setup', this.setup.bind(this));
test('setup', this.setup.bind(this));
}
Fixtures.prototype.teardown = function (test) {
var self = this;
Fixtures.prototype.teardown = function(test) {
var self = this;
test('teardown', function (t) {
self.fixedServer.destroy(t.end);
});
test('teardown', function(t) {
self.fixedServer.destroy(t.end);
});
};
Fixtures.prototype.addFixture = function addFixture(route, response, useToken) {
var self = this;
var self = this;
self.fixtureNames.push(route);
self.fixtureNames.push(route);
self.fixedServer.installFixture({
method: !useToken ? 'post' : 'get',
route: route,
response: function (req, res) {
res.json(response);
}
});
self.fixedServer.installFixture({
method: !useToken ? 'post' : 'get',
route: route,
response: function(req, res) {
res.json(response);
}
});
};
Fixtures.prototype.setup = function setup(t) {
var self = this;
var self = this;
parallel({
tmpName: tmp.tmpName,
tokenTmpName: tmp.tmpName,
port: getport
}, function (err, results) {
if (err) throw err;
parallel({
tmpName: tmp.tmpName,
tokenTmpName: tmp.tmpName,
port: getport
}, function(err, results) {
if (err) throw err;
self.configFile = results.tmpName;
self.tokenConfigFile = results.tokenTmpName
self.port = results.port;
self.configFile = results.tmpName;
self.tokenConfigFile = results.tokenTmpName;
self.port = results.port;
self.fixedServer = new FixedServer({
port: self.port
});
self.fixedServer = new FixedServer({
port: self.port
});
self.host = 'http:\/\/localhost:' + self.port + '\/api\/';
self.arcConfig = {hosts: {}};
self.arcConfig.hosts[self.host] = {
'user': 'test',
'cert': 'test-certificate'
};
self.host = 'http:\/\/localhost:' + self.port + '\/api\/';
self.arcConfig = {
hosts: {}
};
self.arcConfig.hosts[self.host] = {
'user': 'test',
'cert': 'test-certificate'
};
self.tokenArcConfig = {hosts:{}};
self.tokenArcConfig.hosts[self.host] = {
token: 'test-token'
};
self.tokenArcConfig = {
hosts: {}
};
self.tokenArcConfig.hosts[self.host] = {
token: 'test-token'
};
fs.writeFileSync(self.configFile, JSON.stringify(self.arcConfig));
fs.writeFileSync(self.tokenConfigFile, JSON.stringify(self.tokenArcConfig));
fs.writeFileSync(self.configFile, JSON.stringify(self.arcConfig));
fs.writeFileSync(self.tokenConfigFile, JSON.stringify(self.tokenArcConfig));
self.fixtureNames = [];
self.fixtureNames = [];
self.addFixture('/api/conduit.connect', {
'result': {
'connectionID': 12345,
'sessionKey': 'secret-key',
'userPHID': 'PHID-USER-12345'
},
'error_code': null,
'error_info': null
});
self.addFixture('/api/conduit.connect', {
'result': {
'connectionID': 12345,
'sessionKey': 'secret-key',
'userPHID': 'PHID-USER-12345'
},
'error_code': null,
'error_info': null
});
self.fixedServer.listen();
t.end();
});
self.fixedServer.listen();
t.end();
});
};

@@ -7,2 +7,54 @@ var test = require('tape');

function shouldError(t) {
return function (err, canduit) {
t.ok(err, 'should call back with an error');
t.ok(!canduit, 'should not create a canduit instance');
t.end();
};
}
function shouldReportServerError(t) {
return function (err, result) {
t.ok(err, 'should call back with an error');
t.ok(err.code === 'ECONNREFUSED', 'should match the client error');
t.ok(!result, 'should not call back with data');
t.end();
};
}
function shouldReportClientError(t) {
return function (err, result) {
t.ok(err, 'should call back with a error');
t.ok(err.code === 400, 'should match the canduit error');
t.ok(!result, 'should not call back with data');
t.end();
};
}
function shouldReportNotFoundError(t) {
return function (err, result) {
t.ok(err, 'should call back with an error');
t.ok(err.code === 404, 'should match the server error');
t.ok(!result, 'should not call back with data');
t.end();
};
}
function shouldSucceed(t) {
return function (err, canduit) {
t.error(err);
t.ok(canduit, 'should create canduit instance');
t.ok(canduit.session, 'should record canduit session credentials');
t.end();
};
}
function shouldCallBack(t) {
return function (err, users) {
t.error(err);
t.ok(users, 'should call back with canduit API response');
t.end();
};
}
test('creating canduit instance without parameters', function (t) {

@@ -18,7 +70,3 @@ t.doesNotThrow(function () {

configFile: 'not.there'
}, function (err, canduit) {
t.ok(err, 'should call back with an error');
t.ok(!canduit, 'should not create a canduit instance');
t.end();
});
}, shouldError(t));
});

@@ -29,7 +77,3 @@

configFile: __filename
}, function (err, canduit) {
t.ok(err, 'should call back with an error');
t.ok(!canduit, 'should not create a canduit instance');
t.end();
});
}, shouldError(t));
});

@@ -40,8 +84,3 @@

configFile: fixtures.configFile
}, function (err, canduit) {
t.error(err);
t.ok(canduit, 'should create canduit instance');
t.ok(canduit.session, 'should record canduit session credentials');
t.end();
});
}, shouldSucceed(t));
});

@@ -54,8 +93,3 @@

api: 'http://localhost:' + fixtures.port + '/api/'
}, function (err, canduit) {
t.error(err);
t.ok(canduit, 'should create canduit instance');
t.ok(canduit.session, 'should record canduit session credentials');
t.end();
});
}, shouldSucceed(t));
});

@@ -79,7 +113,3 @@

usernames: ['aleksey']
}, function (err, users) {
t.error(err);
t.ok(users, 'should call back with canduit API response');
t.end();
});
}, shouldCallBack(t));
});

@@ -100,8 +130,3 @@ });

data: ['test']
}, function (err, result) {
t.ok(err, 'should call back with a error');
t.ok(err.code === 400, 'should match the canduit error');
t.ok(!result, 'should not call back with data');
t.end();
});
}, shouldReportClientError(t));
});

@@ -117,8 +142,3 @@ });

data: ['test']
}, function (err, result) {
t.ok(err, 'should call back with an error');
t.ok(err.code === 404, 'should match the server error');
t.ok(!result, 'should not call back with data');
t.end();
});
}, shouldReportNotFoundError(t));
});

@@ -150,7 +170,3 @@ });

usernames: ['aleksey']
}, function (err, users) {
t.error(err);
t.ok(users, 'should call back with canduit API response');
t.end();
});
}, shouldCallBack(t));
});

@@ -173,7 +189,3 @@ });

t.error(err);
canduit.exec('user.query', null, function (err, users) {
t.error(err);
t.ok(users, 'should call back with canduit API response');
t.end();
});
canduit.exec('user.query', null, shouldCallBack(t));
});

@@ -189,12 +201,6 @@ });

data: ['test']
}, function (err, result) {
t.ok(err, 'should call back with an error');
t.ok(err.code === 'ECONNREFUSED', 'should match the client error');
t.ok(!result, 'should not call back with data');
t.end();
});
}, shouldReportServerError(t));
});
});
test('requesting conduit api route that returns an error with token', function (t) {

@@ -212,8 +218,3 @@ fixtures.addFixture('/api/error', {

data: ['test']
}, function (err, result) {
t.ok(err, 'should call back with a error');
t.ok(err.code === 400, 'should match the canduit error');
t.ok(!result, 'should not call back with data');
t.end();
});
}, shouldReportClientError(t));
});

@@ -229,8 +230,3 @@ });

data: ['test']
}, function (err, result) {
t.ok(err, 'should call back with an error');
t.ok(err.code === 404, 'should match the server error');
t.ok(!result, 'should not call back with data');
t.end();
});
}, shouldReportNotFoundError(t));
});

@@ -247,8 +243,3 @@ });

data: ['test']
}, function (err, result) {
t.ok(err, 'should call back with an error');
t.ok(err.code === 'ECONNREFUSED', 'should match the client error');
t.ok(!result, 'should not call back with data');
t.end();
});
}, shouldReportServerError(t));
});

@@ -255,0 +246,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc