mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
test(route) render ddos
This commit is contained in:
parent
6a67e57344
commit
396919fe6c
1 changed files with 39 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue