2017-04-19 14:15:28 -05:00
|
|
|
'use strict';
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
require('./lib/startup');
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const exec = require('child_process').exec;
|
2013-12-19 10:11:54 -05:00
|
|
|
|
|
|
|
describe('Func', function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
const server = process.server;
|
|
|
|
const server2 = process.server2;
|
2013-12-29 01:40:47 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
before(function(done) {
|
|
|
|
Promise.all([
|
|
|
|
require('./lib/startup').start('./test-storage', './config-1.yaml'),
|
|
|
|
require('./lib/startup').start('./test-storage2', './config-2.yaml'),
|
|
|
|
]).then(() => {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
before(function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
return Promise.all([server, server2].map(function(server) {
|
|
|
|
return server.debug().status(200).then(function(body) {
|
|
|
|
server.pid = body.pid;
|
|
|
|
return new Promise(function(resolve, reject) {
|
2015-04-11 12:11:04 -05:00
|
|
|
exec('lsof -p ' + Number(server.pid), function(err, result) {
|
2017-04-19 14:15:28 -05:00
|
|
|
assert.equal(err, null);
|
|
|
|
server.fdlist = result.replace(/ +/g, ' ');
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
});
|
2014-09-24 20:21:59 -05:00
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
before(function auth() {
|
2017-04-19 14:15:28 -05:00
|
|
|
return Promise.all([server, server2].map(function(server, cb) {
|
|
|
|
return server.auth('test', 'test').status(201).body_ok(/'test'/);
|
|
|
|
}));
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
it('authenticate', function() {/* test for before() */});
|
2014-09-24 20:21:59 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
require('./access')();
|
|
|
|
require('./basic')();
|
|
|
|
require('./gh29')();
|
|
|
|
require('./tags')();
|
|
|
|
require('./gzip')();
|
|
|
|
require('./incomplete')();
|
|
|
|
require('./mirror')();
|
|
|
|
require('./newnpmreg')();
|
|
|
|
require('./nullstorage')();
|
|
|
|
require('./race')();
|
|
|
|
require('./racycrash')();
|
|
|
|
require('./scoped')();
|
|
|
|
require('./security')();
|
|
|
|
require('./adduser')();
|
|
|
|
require('./logout')();
|
|
|
|
require('./addtag')();
|
|
|
|
require('./plugins')();
|
2015-03-28 13:30:19 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
after(function(done) {
|
|
|
|
const check = (server) => {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
exec('lsof -p ' + parseInt(server.pid, 10), function(err, result) {
|
|
|
|
if (err) {
|
|
|
|
reject();
|
|
|
|
} else {
|
|
|
|
result = result.split('\n').filter(function(q) {
|
|
|
|
if (q.match(/TCP .*->.* \(ESTABLISHED\)/)) return false;
|
|
|
|
if (q.match(/\/libcrypt-[^\/]+\.so/)) return false;
|
|
|
|
if (q.match(/\/node_modules\/crypt3\/build\/Release/)) return false;
|
|
|
|
return true;
|
|
|
|
}).join('\n').replace(/ +/g, ' ');
|
|
|
|
assert.equal(server.fdlist, result);
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Promise.all([check(server), check(server2)]).then(function() {
|
|
|
|
done();
|
|
|
|
}, (reason) => {
|
|
|
|
assert.equal(reason, null);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
process.on('unhandledRejection', function(err) {
|
|
|
|
process.nextTick(function() {
|
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
});
|