0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/functional/index.js

121 lines
3.1 KiB
JavaScript
Raw Normal View History

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');
2017-06-30 16:11:12 -05:00
const _ = require('lodash');
2017-04-19 14:15:28 -05:00
const assert = require('assert');
const exec = require('child_process').exec;
2013-12-19 10:11:54 -05:00
describe('Create registry servers', function() {
2017-04-19 14:15:28 -05:00
const server = process.server;
const server2 = process.server2;
2017-03-03 18:39:26 -05:00
const server3 = process.server3;
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('./store/test-storage', '/store/config-1.yaml'),
require('./lib/startup').start('./store/test-storage2', '/store/config-2.yaml'),
require('./lib/startup').start('./store/test-storage3', '/store/config-3.yaml'),
2017-04-19 14:15:28 -05:00
]).then(() => {
done();
});
2017-04-19 14:15:28 -05:00
});
2013-12-19 10:11:54 -05:00
before(function() {
2017-03-03 18:39:26 -05:00
return Promise.all([server, server2, server3].map(function(server) {
2017-04-19 14:15:28 -05:00
return server.debug().status(200).then(function(body) {
server.pid = body.pid;
2017-04-19 14:15:28 -05:00
return new Promise(function(resolve, reject) {
exec('lsof -p ' + Number(server.pid), function(err, result) {
2017-06-30 16:11:12 -05:00
if (_.isNil(err) === false) {
reject(err);
}
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
before(function testBasicAuthentication() {
return Promise.all([server, server2, server3].map(function(server) {
// log in on server1
return server.auth('test', 'test')
.status(201)
.body_ok(/'test'/);
2017-04-19 14:15:28 -05:00
}));
});
2013-12-19 10:11:54 -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')();
require('./notify')();
// requires packages published to server1/server2
require('./uplink.cache')();
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) {
2017-06-30 16:11:12 -05:00
exec(`lsof -p ${parseInt(server.pid, 10)}`, function(err, result) {
2017-04-19 14:15:28 -05:00
if (err) {
reject();
} else {
2017-06-30 16:11:12 -05: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 14:15:28 -05:00
return true;
}).join('\n').replace(/ +/g, ' ');
assert.equal(server.fdlist, result);
resolve();
}
});
});
};
2017-03-03 18:39:26 -05:00
Promise.all([check(server), check(server2), check(server3)]).then(function() {
2017-04-19 14:15:28 -05:00
done();
}, (reason) => {
assert.equal(reason, null);
done();
});
2017-04-19 14:15:28 -05:00
});
});
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;
});
});