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

124 lines
3.4 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('Create registry servers', 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('./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 21:15:28 +02:00
]).then(() => {
done();
});
2017-04-19 21:15:28 +02:00
});
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;
2017-04-19 21:15:28 +02:00
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 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 21:15:28 +02:00
}));
});
2013-12-19 16:11:54 +01:00
it('authenticate', function() {
/* test for before() */
});
2014-09-25 03:21:59 +02:00
2017-08-02 20:45:21 +02:00
require('./package/access')();
2017-04-19 21:15:28 +02:00
require('./basic')();
require('./gh29')();
require('./tags/tags')();
require('./package/gzip.spec')();
require('./sanity/incomplete')();
require('./sanity/mirror')();
require('./tags/preserve_tags.spec')();
require('./readme/readme.spec')();
require('./sanity/nullstorage')();
require('./performance/race')();
require('./sanity/racycrash')();
require('./package/scoped.spec')();
require('./sanity/security')();
require('./adduser/adduser')();
2017-08-02 20:45:21 +02:00
require('./adduser/logout')();
require('./tags/addtag.spec')();
require('./plugins/auth.spec')();
require('./plugins/middleware.spec')();
2017-08-02 20:45:21 +02:00
require('./notifications/notify')();
// requires packages published to server1/server2
require('./uplink.cache.spec')();
2017-09-30 05:06:42 +02:00
require('./uplink.auth.spec')();
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();
});
2017-04-19 21:15:28 +02:00
});
});
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;
});
});