0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

Validate package name when doing search

+ tests

fix #122
This commit is contained in:
Alex Kocharin 2014-10-02 11:14:59 +04:00
parent 4b3939ef4e
commit eda8dfe9ca
3 changed files with 46 additions and 2 deletions

View file

@ -463,7 +463,7 @@ Storage.prototype.get_recent_packages = function(startkey, callback) {
files.forEach(function(file) {
fs.stat(storage.path, function(err, stats) {
if (err) return callback(err)
if (stats.mtime > startkey) {
if (stats.mtime > startkey && utils.validate_name(file)) {
list.push({
time: stats.mtime,
name: file

View file

@ -4,7 +4,7 @@ users:
test:
password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
users_file: ./test-storage/htpasswd
users_file: ./test-storage/.htpasswd
max_users: 1
web:

View file

@ -11,6 +11,7 @@ function sha(x) {
module.exports = function() {
var server = process.server
var server2 = process.server2
var express = process.express
describe('newnpmreg', function() {
before(function(cb) {
@ -84,5 +85,48 @@ module.exports = function() {
cb()
})
})
describe('search', function() {
function check(obj) {
obj.testpkg.time.modified = '2014-10-02T07:07:51.000Z'
assert.deepEqual(obj.testpkg, {
"name": "testpkg",
"dist-tags": {
"latest": "0.0.1"
},
"maintainers": [],
"readmeFilename": "",
"time": {
"modified": "2014-10-02T07:07:51.000Z"
},
"versions": {
"0.0.1": "latest"
}
})
}
before(function(cb) {
express.get('/-/all', function(req, res) {
res.send({})
})
cb()
})
it('server1 - search', function(cb) {
server.request({uri:'/-/all'}, function(err, res, body) {
assert.equal(res.statusCode, 200)
check(body)
cb()
})
})
it('server2 - search', function(cb) {
server2.request({uri:'/-/all'}, function(err, res, body) {
assert.equal(res.statusCode, 200)
check(body)
cb()
})
})
})
})
}