From 396919fe6c9b3b3658f882f66826d2121ca1f7a3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 25 Apr 2018 16:54:30 +0300 Subject: [PATCH] test(route) render ddos --- test/server/route.js | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/server/route.js b/test/server/route.js index f259fc3e..3735d5c9 100644 --- a/test/server/route.js +++ b/test/server/route.js @@ -2,6 +2,7 @@ const path = require('path'); const fs = require('fs'); + const test = require('tape'); const {promisify} = require('es6-promisify'); const pullout = require('pullout'); @@ -9,10 +10,11 @@ const request = require('request'); const mockRequire = require('mock-require'); const clear = require('clear-module'); -const rootDir = '../..'; +const rootDir = path.join(__dirname, '../..'); const routePath = `${rootDir}/server/route`; -const beforePath = '../before'; +const cloudcmdPath = `${rootDir}/server/cloudcmd`; +const beforePath = path.join(__dirname, '../before'); const { _getIndexPath, @@ -349,6 +351,41 @@ test('cloudcmd: route: sendIndex: encode: not encoded', async (t) => { t.end(); }); +test('cloudcmd: route: sendIndex: ddos: render', async (t) => { + const name = '$$$\'"'; + const files = [{ + name, + }]; + + const read = (path, fn) => fn(null, { + path, + files, + }); + + mockRequire('flop', { + read + }); + + clear(routePath); + clear(cloudcmdPath); + clear(beforePath); + + const {connect} = require(beforePath); + const {port, done} = await connect(); + + await getStr(`http://localhost:${port}`); + + t.pass('should not hang up'); + + clear('flop'); + clear(routePath); + clear(cloudcmdPath); + clear(beforePath); + + done(); + t.end(); +}); + test('cloudcmd: route: buttons: no terminal', async (t) => { const config = { terminal: false