Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: test static plugin's handling of sprintf escape sequences (#1391)
  • Loading branch information
trentm authored and William Blankenship committed Jun 28, 2017
1 parent 80af137 commit 5d7039a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/plugins/static.test.js
Expand Up @@ -232,6 +232,37 @@ describe('static resource plugin', function () {
testNoAppendPath(done, false, '.tmp', null, true);
});

it('static responds 404 for missing file', function (done) {
var p = '/public/no-such-file.json';
var tmpPath = path.join(process.cwd(), '.tmp');

SERVER.get(new RegExp('/public/.*'),
restify.plugins.serveStatic({directory: tmpPath}));

CLIENT.get(p, function (err, req, res, obj) {
assert.ok(err);
assert.strictEqual(err.statusCode, 404);
assert.strictEqual(err.restCode, 'ResourceNotFound');
done();
});
});

it('GH-1382 static responds 404 for missing file with percent-codes',
function (done) {
var p = '/public/no-%22such-file.json';
var tmpPath = path.join(process.cwd(), '.tmp');

SERVER.get(new RegExp('/public/.*'),
restify.plugins.serveStatic({directory: tmpPath}));

CLIENT.get(p, function (err, req, res, obj) {
assert.ok(err);
assert.equal(err.statusCode, 404);
assert.equal(err.restCode, 'ResourceNotFound');
done();
});
});

// To ensure this will always get properly restored (even in case of a test
// failure) we do it here.
var originalCreateReadStream = fs.createReadStream;
Expand Down

0 comments on commit 5d7039a

Please sign in to comment.