Skip to content

Commit

Permalink
adds failing test to ensure files and directories that start with und…
Browse files Browse the repository at this point in the history
…erscore are not served.
  • Loading branch information
sintaxi committed Jun 2, 2021
1 parent fd49cbc commit 6547336
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/apps/security/_secret.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secret text
42 changes: 42 additions & 0 deletions test/security.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var should = require("should")
var request = require('request')
var path = require("path")
var fs = require("fs")
var exec = require("child_process").exec
var harp = require("../")

describe("security", function(){
var projectPath = path.join(__dirname, "apps/security")
var outputPath = path.join(__dirname, "out/security")

var config;

before(function(done){
harp.compile(projectPath, outputPath, function(errors, output){
config = output
var server = harp.server(projectPath)
server.listen(8101, done)
})
})

it("should not serve file starting with underscore", function(done){
request('http://localhost:8101/_secret.txt', function (e, r, b) {
r.statusCode.should.eql(404)
done()
})
})

it("should not serve file starting with encoded underscore", function(done){
request('http://localhost:8101/%5fsecret.txt', function (e, r, b) {
r.statusCode.should.eql(404)
done()
})
})

after(function(done){
exec("rm -rf " + outputPath, function(){
done()
})
})

})

0 comments on commit 6547336

Please sign in to comment.