mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
update
This commit is contained in:
parent
835841707a
commit
21ad8945d9
9 changed files with 104 additions and 67 deletions
|
@ -32,7 +32,7 @@ module.exports = function(config_hash) {
|
|||
app.use(etagify);
|
||||
app.use(basic_auth(function(user, pass) {
|
||||
return config.authenticate(user, pass);
|
||||
}));
|
||||
}));
|
||||
app.use(express.bodyParser());
|
||||
|
||||
// TODO: npm DO NOT support compression :(
|
||||
|
|
16
lib/multiplexer.js
Normal file
16
lib/multiplexer.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
module.exports = function() {
|
||||
local_store()
|
||||
for each uplink
|
||||
status = uplink_store()
|
||||
if (status == 201) {
|
||||
succeess.push(uplink)
|
||||
} else {
|
||||
bail()
|
||||
}
|
||||
|
||||
bail:
|
||||
local_revert()
|
||||
uplink_revert()
|
||||
};
|
||||
*/
|
|
@ -14,7 +14,7 @@ ex['trying to fetch non-existent package'] = function(cb) {
|
|||
};
|
||||
|
||||
ex['creating new package'] = function(cb) {
|
||||
server.put_package('testpkg', readfile('fixtures/test-package.json'), function(res, body) {
|
||||
server.put_package('testpkg', require('./lib/package')('testpkg'), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(~body.ok.indexOf('created new package'));
|
||||
cb();
|
||||
|
@ -52,7 +52,7 @@ 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) {
|
||||
server.put_version('testpkg', '0.0.1', require('./lib/package')('testpkg'), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(~body.ok.indexOf('published'));
|
||||
cb();
|
||||
|
@ -63,9 +63,9 @@ ex['downloading newly created package'] = function(cb) {
|
|||
server.get_package('testpkg', function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(body.name, 'testpkg');
|
||||
assert.equal(body.versions['0.0.1'].name, 'testpkg');
|
||||
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55551/testpkg/-/blahblah');
|
||||
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
|
||||
assert.equal(body.versions['0.0.1'].name, 'testpkg');
|
||||
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55551/testpkg/-/blahblah');
|
||||
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
@ -74,9 +74,9 @@ ex['downloading package via server2'] = function(cb) {
|
|||
server2.get_package('testpkg', function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(body.name, 'testpkg');
|
||||
assert.equal(body.versions['0.0.1'].name, 'testpkg');
|
||||
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55552/testpkg/-/blahblah');
|
||||
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
|
||||
assert.equal(body.versions['0.0.1'].name, 'testpkg');
|
||||
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55552/testpkg/-/blahblah');
|
||||
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -14,6 +14,12 @@ packages:
|
|||
allow_publish: all
|
||||
proxy_access: server2
|
||||
proxy_publish: server2
|
||||
|
||||
'testloop':
|
||||
allow_access: all
|
||||
allow_publish: all
|
||||
proxy_access: server2
|
||||
proxy_publish: server2
|
||||
|
||||
'*':
|
||||
allow_access: test anonymous
|
||||
|
|
|
@ -12,6 +12,12 @@ packages:
|
|||
'testfwd':
|
||||
allow_access: all
|
||||
allow_publish: all
|
||||
|
||||
'testloop':
|
||||
allow_access: all
|
||||
allow_publish: all
|
||||
proxy_access: server1
|
||||
proxy_publish: server1
|
||||
|
||||
testpkg:
|
||||
allow_access: test anonymous
|
||||
|
|
8
test/fixtures/fwd-package.json
vendored
8
test/fixtures/fwd-package.json
vendored
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"name": "testfwd",
|
||||
"version": "0.0.0",
|
||||
"dist": {
|
||||
"shasum": "fake",
|
||||
"tarball": "http://localhost:55551/testpkg/-/blahblah"
|
||||
}
|
||||
}
|
8
test/fixtures/test-package.json
vendored
8
test/fixtures/test-package.json
vendored
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"name": "testpkg",
|
||||
"version": "0.0.0",
|
||||
"dist": {
|
||||
"shasum": "fake",
|
||||
"tarball": "http://localhost:55551/testpkg/-/blahblah"
|
||||
}
|
||||
}
|
12
test/lib/package.js
Normal file
12
test/lib/package.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
module.exports = function(name) {
|
||||
return {
|
||||
"name": name,
|
||||
"version": "0.0.0",
|
||||
"dist": {
|
||||
"shasum": "fake",
|
||||
"tarball": "http://localhost:55551/"+escape(name)+"/-/blahblah"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -4,51 +4,64 @@ var ex = module.exports;
|
|||
var server = process.server;
|
||||
var server2 = process.server2;
|
||||
|
||||
ex['creating new package'] = function(cb) {
|
||||
server.put_package('testfwd', readfile('fixtures/fwd-package.json'), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(~body.ok.indexOf('created new package'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
['fwd', 'loop'].forEach(function(pkg) {
|
||||
var prefix = pkg+': ';
|
||||
pkg = 'test'+pkg;
|
||||
|
||||
ex['uploading new package version'] = function(cb) {
|
||||
server.put_version('testfwd', '0.1.1', readfile('fixtures/fwd-package.json'), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(~body.ok.indexOf('published'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
ex[prefix+'creating new package'] = function(cb) {
|
||||
server.put_package(pkg, require('./lib/package')(pkg), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(~body.ok.indexOf('created new package'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['downloading package via server2'] = function(cb) {
|
||||
server2.get_package('testfwd', function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(body.name, 'testfwd');
|
||||
assert.equal(body.versions['0.1.1'].name, 'testfwd');
|
||||
assert.equal(body.versions['0.1.1'].dist.tarball, 'http://localhost:55552/testpkg/-/blahblah');
|
||||
cb();
|
||||
});
|
||||
};
|
||||
ex[prefix+'uploading new package version'] = function(cb) {
|
||||
server.put_version(pkg, '0.1.1', require('./lib/package')(pkg), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(~body.ok.indexOf('published'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['uploading incomplete tarball'] = function(cb) {
|
||||
server.put_tarball_incomplete('testfwd', 'testfwd.bad', readfile('fixtures/binary'), 3000, function(res, body) {
|
||||
cb();
|
||||
});
|
||||
};
|
||||
ex[prefix+'downloading package via server2'] = function(cb) {
|
||||
server2.get_package(pkg, function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(body.name, pkg);
|
||||
assert.equal(body.versions['0.1.1'].name, pkg);
|
||||
assert.equal(body.versions['0.1.1'].dist.tarball, 'http://localhost:55552/'+pkg+'/-/blahblah');
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['uploading new tarball'] = function(cb) {
|
||||
server.put_tarball('testfwd', 'testfwd.file', readfile('fixtures/binary'), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(body.ok);
|
||||
cb();
|
||||
});
|
||||
};
|
||||
ex[prefix+'uploading incomplete tarball'] = function(cb) {
|
||||
server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000, function(res, body) {
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex['downloading tarball from server2'] = function(cb) {
|
||||
server2.get_tarball('testfwd', 'testfwd.file', function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
ex[prefix+'uploading new tarball'] = function(cb) {
|
||||
server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'), function(res, body) {
|
||||
assert.equal(res.statusCode, 201);
|
||||
assert(body.ok);
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex[prefix+'downloading tarball from server1'] = function(cb) {
|
||||
server.get_tarball(pkg, pkg+'.file', function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
ex[prefix+'downloading tarball from server2'] = function(cb) {
|
||||
server2.get_tarball(pkg, pkg+'.file', function(res, body) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue