Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad Request for invalid database names #214

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"promise-nodify": "^1.0.2",
"random-uuid-v4": "0.0.6",
"raw-body": "^2.2.0",
"sanitize-filename": "^1.6.1",
"serve-favicon": "~2.3.2",
"tail": "^1.2.1",
"uuid": "^3.0.1",
Expand Down
12 changes: 0 additions & 12 deletions packages/node_modules/express-pouchdb/lib/clean-filename.js

This file was deleted.

37 changes: 37 additions & 0 deletions packages/node_modules/express-pouchdb/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions packages/node_modules/express-pouchdb/lib/routes/db.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/node_modules/express-pouchdb/lib/routes/rewrite.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/node_modules/express-pouchdb/lib/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions tests/express-pouchdb/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,42 @@ describe('redirects', function () {
});
});

describe('invalid databases (#213)', function () {
it('GET /_invalid should return 400 Bad Request', function (done) {
request(coreApp)
.get('/_invalid')
.expect(400)
.expect(function (res) {
var error = JSON.parse(res.text);
if (error.error !== 'illegal_database_name') {
return 'should return "illegal_database_name" error';
}
if (!/Name: '_invalid'/.test(error.reasons)) {
return 'should return "reason"';
}
})
.end(done);
});

it('GET /_internal should not return 400 Bad Request', function (done) {
// router handler is never called because it’s already handled by the
// `GET /:db` handler which returns a 404, as no `_internal` db exists
coreApp.get('/_internal', function () {});

request(coreApp)
.get('/_internal')
.expect(404)
.end(done);
});

it('GET /user%2Fabc4567 should not return 400 Bad Request', function (done) {
request(coreApp)
.get('/user%2Fabc4567')
.expect(404)
.end(done);
});
});

function assertException(func, re) {
var e;
try {
Expand Down