From 281e115e683fa522332ffba4fdf52b1671693ba5 Mon Sep 17 00:00:00 2001 From: Jay Kuri Date: Mon, 21 Oct 2019 19:53:52 -0600 Subject: [PATCH] tests: add tests for non-existent root path closes #129 --- test/test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test.js b/test/test.js index 9419957..e1e3fd1 100644 --- a/test/test.js +++ b/test/test.js @@ -580,6 +580,25 @@ describe('serveStatic()', function () { }) }) + describe('when non-existent root path', function () { + var server + before(function () { + server = createServer(fixtures + '/does_not_exist') + }) + + it('should 404 for any file', function (done) { + request(server) + .get('/todo.txt') + .expect(404, done) + }) + + it('should not allow traversal', function (done) { + request(server) + .get('/../todo.txt') + .expect(404, done) + }) + }) + describe('when traversing past root', function () { before(function () { this.server = createServer(fixtures, { fallthrough: false })