1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/functional/index.js

109 lines
3.0 KiB
JavaScript
Raw Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
2013-12-19 16:11:54 +01:00
2017-04-19 21:15:28 +02:00
require('./lib/startup');
2017-06-30 23:11:12 +02:00
const _ = require('lodash');
2017-04-19 21:15:28 +02:00
const assert = require('assert');
const exec = require('child_process').exec;
2013-12-19 16:11:54 +01:00
describe('Func', function() {
2017-04-19 21:15:28 +02:00
const server = process.server;
const server2 = process.server2;
2017-03-04 00:39:26 +01:00
const server3 = process.server3;
2013-12-29 07:40:47 +01:00
2017-04-19 21:15:28 +02:00
before(function(done) {
Promise.all([
require('./lib/startup').start('./test-storage', './config-1.yaml'),
require('./lib/startup').start('./test-storage2', './config-2.yaml'),
2017-03-04 00:39:26 +01:00
require('./lib/startup').start('./test-storage3', './config-3.yaml'),
2017-04-19 21:15:28 +02:00
]).then(() => {
done();
});
});
2013-12-19 16:11:54 +01:00
before(function() {
2017-03-04 00:39:26 +01:00
return Promise.all([server, server2, server3].map(function(server) {
2017-04-19 21:15:28 +02:00
return server.debug().status(200).then(function(body) {
server.pid = body.pid;
return new Promise(function(resolve, reject) {
exec('lsof -p ' + Number(server.pid), function(err, result) {
2017-06-30 23:11:12 +02:00
if (_.isNil(err) === false) {
reject(err);
}
2017-04-19 21:15:28 +02:00
assert.equal(err, null);
server.fdlist = result.replace(/ +/g, ' ');
resolve();
});
});
});
}));
});
2014-09-25 03:21:59 +02:00
before(function auth() {
2017-03-04 00:39:26 +01:00
return Promise.all([server, server2, server3].map(function(server, cb) {
2017-04-19 21:15:28 +02:00
return server.auth('test', 'test').status(201).body_ok(/'test'/);
}));
});
2013-12-19 16:11:54 +01:00
2017-04-19 21:15:28 +02:00
it('authenticate', function() {/* test for before() */});
2014-09-25 03:21:59 +02:00
2017-04-19 21:15:28 +02: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')();
2017-03-04 00:39:26 +01:00
// requires packages published to server1/server2
require('./gh131')();
2015-03-28 19:30:19 +01:00
2017-04-19 21:15:28 +02:00
after(function(done) {
const check = (server) => {
return new Promise(function(resolve, reject) {
2017-06-30 23:11:12 +02:00
exec(`lsof -p ${parseInt(server.pid, 10)}`, function(err, result) {
2017-04-19 21:15:28 +02:00
if (err) {
reject();
} else {
2017-06-30 23:11:12 +02:00
result = result.split('\n').filter(function(query) {
if (query.match(/TCP .*->.* \(ESTABLISHED\)/)) {
return false;
}
if (query.match(/\/libcrypt-[^\/]+\.so/)) {
return false;
}
if (query.match(/\/node_modules\/crypt3\/build\/Release/)) {
return false;
}
2017-04-19 21:15:28 +02:00
return true;
}).join('\n').replace(/ +/g, ' ');
assert.equal(server.fdlist, result);
resolve();
}
});
});
};
2017-03-04 00:39:26 +01:00
Promise.all([check(server), check(server2), check(server3)]).then(function() {
2017-04-19 21:15:28 +02:00
done();
}, (reason) => {
assert.equal(reason, null);
done();
});
});
});
2013-12-19 16:11:54 +01:00
2017-04-19 21:15:28 +02:00
process.on('unhandledRejection', function(err) {
process.nextTick(function() {
throw err;
});
});