Skip to content

Commit 281e115

Browse files
jaykdougwilson
authored andcommitted
tests: add tests for non-existent root path
closes #129
1 parent d38eb5b commit 281e115

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,25 @@ describe('serveStatic()', function () {
580580
})
581581
})
582582

583+
describe('when non-existent root path', function () {
584+
var server
585+
before(function () {
586+
server = createServer(fixtures + '/does_not_exist')
587+
})
588+
589+
it('should 404 for any file', function (done) {
590+
request(server)
591+
.get('/todo.txt')
592+
.expect(404, done)
593+
})
594+
595+
it('should not allow traversal', function (done) {
596+
request(server)
597+
.get('/../todo.txt')
598+
.expect(404, done)
599+
})
600+
})
601+
583602
describe('when traversing past root', function () {
584603
before(function () {
585604
this.server = createServer(fixtures, { fallthrough: false })

0 commit comments

Comments
 (0)