2014-12-14 15:29:56 -05:00
|
|
|
var assert = require('assert')
|
|
|
|
|
|
|
|
function readfile(x) {
|
|
|
|
return require('fs').readFileSync(__dirname + '/' + x)
|
|
|
|
}
|
|
|
|
|
|
|
|
function sha(x) {
|
|
|
|
return require('crypto').createHash('sha1', 'binary').update(x).digest('hex')
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function() {
|
|
|
|
var server = process.server
|
|
|
|
var server2 = process.server2
|
|
|
|
|
|
|
|
describe('test-scoped', function() {
|
2015-04-11 12:11:04 -05:00
|
|
|
before(function () {
|
|
|
|
return server.request({
|
2014-12-14 15:29:56 -05:00
|
|
|
uri: '/@test%2fscoped',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
method: 'PUT',
|
|
|
|
json: JSON.parse(readfile('fixtures/scoped.json')),
|
2015-04-11 12:11:04 -05:00
|
|
|
}).status(201)
|
2014-12-14 15:29:56 -05:00
|
|
|
})
|
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it('add pkg', function () {})
|
2014-12-14 15:29:56 -05:00
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it('server1 - tarball', function () {
|
|
|
|
return server.get_tarball('@test/scoped', 'scoped-1.0.0.tgz')
|
|
|
|
.status(200)
|
|
|
|
.then(function (body) {
|
|
|
|
// not real sha due to utf8 conversion
|
2016-07-30 14:02:50 -05:00
|
|
|
assert.strictEqual(sha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790')
|
2015-04-11 12:11:04 -05:00
|
|
|
})
|
2014-12-14 15:29:56 -05:00
|
|
|
})
|
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it('server2 - tarball', function () {
|
|
|
|
return server2.get_tarball('@test/scoped', 'scoped-1.0.0.tgz')
|
|
|
|
.status(200)
|
|
|
|
.then(function (body) {
|
|
|
|
// not real sha due to utf8 conversion
|
2016-07-30 14:02:50 -05:00
|
|
|
assert.strictEqual(sha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790')
|
2015-04-11 12:11:04 -05:00
|
|
|
})
|
2014-12-14 15:29:56 -05:00
|
|
|
})
|
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it('server1 - package', function () {
|
|
|
|
return server.get_package('@test/scoped')
|
|
|
|
.status(200)
|
|
|
|
.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 15:29:56 -05:00
|
|
|
})
|
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it('server2 - package', function () {
|
|
|
|
return server2.get_package('@test/scoped')
|
|
|
|
.status(200)
|
|
|
|
.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'})
|
|
|
|
})
|
2014-12-14 15:29:56 -05:00
|
|
|
})
|
2015-06-28 20:10:54 -05:00
|
|
|
|
|
|
|
it('server2 - nginx workaround', function () {
|
|
|
|
return server2.request({ uri: '/@test/scoped/1.0.0' })
|
|
|
|
.status(200)
|
|
|
|
.then(function (body) {
|
|
|
|
assert.equal(body.name, '@test/scoped')
|
|
|
|
assert.equal(body.dist.tarball, 'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz')
|
|
|
|
})
|
|
|
|
})
|
2014-12-14 15:29:56 -05:00
|
|
|
})
|
|
|
|
}
|