mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
testing fetching files from uplinks
This commit is contained in:
parent
8fe23d3393
commit
361d653613
5 changed files with 75 additions and 21 deletions
|
@ -6,7 +6,11 @@ users:
|
|||
|
||||
packages:
|
||||
'*':
|
||||
allow_access: test
|
||||
allow_publish: test
|
||||
allow_access: test anonymous
|
||||
allow_publish: test anonymous
|
||||
|
||||
# this should not matter
|
||||
testpkg:
|
||||
allow_access: none
|
||||
|
||||
listen: 55551
|
||||
|
|
|
@ -4,9 +4,18 @@ users:
|
|||
test:
|
||||
password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
||||
|
||||
uplinks:
|
||||
server1:
|
||||
url: http://localhost:55551/
|
||||
|
||||
packages:
|
||||
testpkg:
|
||||
allow_access: test anonymous
|
||||
allow_publish: test anonymous
|
||||
proxy_access: server1
|
||||
|
||||
'*':
|
||||
allow_access: test
|
||||
allow_publish: test
|
||||
allow_access: test anonymous
|
||||
allow_publish: test anonymous
|
||||
|
||||
listen: 55552
|
||||
|
|
6
test/fixtures/test-package.json
vendored
6
test/fixtures/test-package.json
vendored
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"name": "testpkg",
|
||||
"version": "0.0.0"
|
||||
"version": "0.0.0",
|
||||
"dist": {
|
||||
"shasum": "fake",
|
||||
"tarball": "http://localhost:55551/testpkg/-/blahblah"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,18 @@ Server.prototype.get_package = function(name, cb) {
|
|||
Server.prototype.put_package = function(name, data, cb) {
|
||||
if (typeof(data) === 'object' && !Buffer.isBuffer(data)) data = JSON.stringify(data);
|
||||
this.request({
|
||||
uri: '/'+name,
|
||||
uri: '/'+escape(name),
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
}, prep(cb)).end(data);
|
||||
}
|
||||
|
||||
Server.prototype.put_version = function(name, version, data, cb) {
|
||||
if (typeof(data) === 'object' && !Buffer.isBuffer(data)) data = JSON.stringify(data);
|
||||
this.request({
|
||||
uri: '/'+escape(name)+'/'+escape(version)+'/-tag/latest',
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
|
@ -60,14 +71,14 @@ Server.prototype.put_package = function(name, data, cb) {
|
|||
|
||||
Server.prototype.get_tarball = function(name, filename, cb) {
|
||||
this.request({
|
||||
uri: '/'+name+'/-/'+filename,
|
||||
uri: '/'+escape(name)+'/-/'+escape(filename),
|
||||
method: 'GET',
|
||||
}, prep(cb));
|
||||
}
|
||||
|
||||
Server.prototype.put_tarball = function(name, filename, data, cb) {
|
||||
this.request({
|
||||
uri: '/'+name+'/-/'+filename+'/whatever',
|
||||
uri: '/'+escape(name)+'/-/'+escape(filename)+'/whatever',
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'content-type': 'application/octet-stream'
|
||||
|
|
|
@ -30,11 +30,15 @@ ex['starting servers'] = function(cb) {
|
|||
start('./test-storage2', './config-2.yaml', cb);
|
||||
};
|
||||
|
||||
ex['authentication to server1'] = function(cb) {
|
||||
server.auth('test', 'test', function(res, body) {
|
||||
assert(res.statusCode === 201);
|
||||
assert.notEqual(body.ok.indexOf('"test"'), -1);
|
||||
cb();
|
||||
ex['authentication to servers'] = function(cb) {
|
||||
var count = 0;
|
||||
[server, server2].forEach(function(server) {
|
||||
count++;
|
||||
server.auth('test', 'test', function(res, body) {
|
||||
assert(res.statusCode === 201);
|
||||
assert.notEqual(body.ok.indexOf('"test"'), -1);
|
||||
if (!--count) cb();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -55,14 +59,6 @@ ex['creating new package'] = function(cb) {
|
|||
});
|
||||
};
|
||||
|
||||
ex['downloading newly created package'] = function(cb) {
|
||||
server.get_package('testpkg', function(res, body) {
|
||||
assert(res.statusCode === 200);
|
||||
assert(body.name === 'testpkg');
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['downloading non-existent tarball'] = function(cb) {
|
||||
server.get_tarball('testpkg', 'blahblah', function(res, body) {
|
||||
assert(res.statusCode === 404);
|
||||
|
@ -87,6 +83,36 @@ ex['downloading newly created tarball'] = function(cb) {
|
|||
});
|
||||
};
|
||||
|
||||
ex['uploading new package version'] = function(cb) {
|
||||
server.put_version('testpkg', '0.0.1', readfile('fixtures/test-package.json'), function(res, body) {
|
||||
assert(res.statusCode === 201);
|
||||
assert(~body.ok.indexOf('published'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['downloading newly created package'] = function(cb) {
|
||||
server.get_package('testpkg', function(res, body) {
|
||||
assert(res.statusCode === 200);
|
||||
assert(body.name === 'testpkg');
|
||||
assert(body.versions['0.0.1'].name === 'testpkg');
|
||||
assert(body.versions['0.0.1'].dist.tarball === 'http://localhost:55551/testpkg/-/blahblah');
|
||||
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['downloading package via server2'] = function(cb) {
|
||||
server2.get_package('testpkg', function(res, body) {
|
||||
assert(res.statusCode === 200);
|
||||
assert(body.name === 'testpkg');
|
||||
assert(body.versions['0.0.1'].name === 'testpkg');
|
||||
assert(body.versions['0.0.1'].dist.tarball === 'http://localhost:55552/testpkg/-/blahblah');
|
||||
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
process.on('exit', function() {
|
||||
if (forks[0]) forks[0].kill();
|
||||
if (forks[1]) forks[1].kill();
|
||||
|
|
Loading…
Reference in a new issue