Skip to content

Commit

Permalink
tests: add tests for non-existent root path
Browse files Browse the repository at this point in the history
closes #129
  • Loading branch information
jayk authored and dougwilson committed Dec 16, 2021
1 parent d38eb5b commit 281e115
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 281e115

Please sign in to comment.