-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds failing test to ensure files and directories that start with und…
…erscore are not served.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
secret text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
}) | ||
|
||
}) |