2017-04-19 21:15:28 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
let assert = require('assert');
|
2014-12-14 21:29:56 +01:00
|
|
|
|
|
|
|
function readfile(x) {
|
2017-04-19 21:15:28 +02:00
|
|
|
return require('fs').readFileSync(__dirname + '/' + x);
|
2014-12-14 21:29:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function sha(x) {
|
2017-04-19 21:15:28 +02:00
|
|
|
return require('crypto').createHash('sha1', 'binary').update(x).digest('hex');
|
2014-12-14 21:29:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function() {
|
2017-04-19 21:15:28 +02:00
|
|
|
let server = process.server;
|
|
|
|
let server2 = process.server2;
|
2014-12-14 21:29:56 +01:00
|
|
|
|
|
|
|
describe('test-scoped', function() {
|
2017-04-19 21:15:28 +02:00
|
|
|
before(function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.request({
|
2014-12-14 21:29:56 +01:00
|
|
|
uri: '/@test%2fscoped',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
method: 'PUT',
|
|
|
|
json: JSON.parse(readfile('fixtures/scoped.json')),
|
2017-04-19 21:15:28 +02:00
|
|
|
}).status(201);
|
|
|
|
});
|
2014-12-14 21:29:56 +01:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('add pkg', function() {});
|
2014-12-14 21:29:56 +01:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('server1 - tarball', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.get_tarball('@test/scoped', 'scoped-1.0.0.tgz')
|
|
|
|
.status(200)
|
2017-04-19 21:15:28 +02:00
|
|
|
.then(function(body) {
|
2015-04-11 19:11:04 +02:00
|
|
|
// not real sha due to utf8 conversion
|
2017-04-19 21:15:28 +02:00
|
|
|
assert.strictEqual(sha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790');
|
|
|
|
});
|
|
|
|
});
|
2014-12-14 21:29:56 +01:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('server2 - tarball', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server2.get_tarball('@test/scoped', 'scoped-1.0.0.tgz')
|
|
|
|
.status(200)
|
2017-04-19 21:15:28 +02:00
|
|
|
.then(function(body) {
|
2015-04-11 19:11:04 +02:00
|
|
|
// not real sha due to utf8 conversion
|
2017-04-19 21:15:28 +02:00
|
|
|
assert.strictEqual(sha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790');
|
|
|
|
});
|
|
|
|
});
|
2014-12-14 21:29:56 +01:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('server1 - package', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.get_package('@test/scoped')
|
|
|
|
.status(200)
|
2017-04-19 21:15:28 +02:00
|
|
|
.then(function(body) {
|
|
|
|
assert.equal(body.name, '@test/scoped');
|
|
|
|
assert.equal(body.versions['1.0.0'].name, '@test/scoped');
|
|
|
|
assert.equal(body.versions['1.0.0'].dist.tarball, 'http://localhost:55551/@test%2fscoped/-/scoped-1.0.0.tgz');
|
|
|
|
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'});
|
|
|
|
});
|
|
|
|
});
|
2014-12-14 21:29:56 +01:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('server2 - package', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server2.get_package('@test/scoped')
|
|
|
|
.status(200)
|
2017-04-19 21:15:28 +02:00
|
|
|
.then(function(body) {
|
|
|
|
assert.equal(body.name, '@test/scoped');
|
|
|
|
assert.equal(body.versions['1.0.0'].name, '@test/scoped');
|
|
|
|
assert.equal(body.versions['1.0.0'].dist.tarball, 'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz');
|
|
|
|
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'});
|
|
|
|
});
|
|
|
|
});
|
2015-06-29 03:10:54 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('server2 - nginx workaround', function() {
|
|
|
|
return server2.request({uri: '/@test/scoped/1.0.0'})
|
2015-06-29 03:10:54 +02:00
|
|
|
.status(200)
|
2017-04-19 21:15:28 +02:00
|
|
|
.then(function(body) {
|
|
|
|
assert.equal(body.name, '@test/scoped');
|
|
|
|
assert.equal(body.dist.tarball, 'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|