mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(route) flop -> win32
This commit is contained in:
parent
3976056ee8
commit
90eae0e944
2 changed files with 44 additions and 7 deletions
|
|
@ -6,6 +6,9 @@
|
|||
"fontello.json"
|
||||
],
|
||||
"match": {
|
||||
"*.js": {
|
||||
"convert-esm-to-commonjs": "on"
|
||||
},
|
||||
"*.md": {
|
||||
"convert-commonjs-to-esm": "on"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const {Readable} = require('stream');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
|
|
@ -25,6 +27,10 @@ const {request} = serveOnce(cloudcmd, {
|
|||
config: defaultConfig,
|
||||
});
|
||||
|
||||
const {stringify} = JSON;
|
||||
|
||||
const {assign} = Object;
|
||||
|
||||
test('cloudcmd: route: buttons: no console', async (t) => {
|
||||
const options = {
|
||||
config: {
|
||||
|
|
@ -222,15 +228,24 @@ test('cloudcmd: route: not found', async (t) => {
|
|||
test('cloudcmd: route: sendIndex: encode', async (t) => {
|
||||
const name = '"><svg onload=alert(3);>';
|
||||
const nameEncoded = '"><svg onload=alert(3);>';
|
||||
const path = '/';
|
||||
const files = [{
|
||||
name,
|
||||
}];
|
||||
|
||||
const read = stub().returns({
|
||||
type: 'directory',
|
||||
const stream = Readable.from(stringify({
|
||||
path,
|
||||
files,
|
||||
}));
|
||||
|
||||
assign(stream, {
|
||||
path,
|
||||
files,
|
||||
type: 'directory',
|
||||
});
|
||||
|
||||
const read = stub().resolves(stream);
|
||||
|
||||
mockRequire('win32', {
|
||||
read,
|
||||
});
|
||||
|
|
@ -242,7 +257,8 @@ test('cloudcmd: route: sendIndex: encode', async (t) => {
|
|||
configManager: createConfigManager(),
|
||||
});
|
||||
|
||||
const {body} = await request.get('/');
|
||||
const response = await request.get('/');
|
||||
const {body} = response;
|
||||
|
||||
stopAll();
|
||||
|
||||
|
|
@ -252,16 +268,25 @@ test('cloudcmd: route: sendIndex: encode', async (t) => {
|
|||
|
||||
test('cloudcmd: route: sendIndex: encode: not encoded', async (t) => {
|
||||
const name = '"><svg onload=alert(3);>';
|
||||
const path = '/';
|
||||
const files = [{
|
||||
name,
|
||||
}];
|
||||
|
||||
const read = async (path) => ({
|
||||
const stream = Readable.from(stringify({
|
||||
path,
|
||||
files,
|
||||
}));
|
||||
|
||||
assign(stream, {
|
||||
path,
|
||||
files,
|
||||
type: 'directory',
|
||||
});
|
||||
|
||||
mockRequire('flop', {
|
||||
const read = stub().resolves(stream);
|
||||
|
||||
mockRequire('win32', {
|
||||
read,
|
||||
});
|
||||
|
||||
|
|
@ -279,16 +304,25 @@ test('cloudcmd: route: sendIndex: encode: not encoded', async (t) => {
|
|||
|
||||
test('cloudcmd: route: sendIndex: ddos: render', async (t) => {
|
||||
const name = '$$$\'"';
|
||||
const path = '/';
|
||||
const files = [{
|
||||
name,
|
||||
}];
|
||||
|
||||
const read = async (path) => ({
|
||||
const stream = Readable.from(stringify({
|
||||
path,
|
||||
files,
|
||||
}));
|
||||
|
||||
assign(stream, {
|
||||
path,
|
||||
files,
|
||||
type: 'directory',
|
||||
});
|
||||
|
||||
mockRequire('flop', {
|
||||
const read = stub().resolves(stream);
|
||||
|
||||
mockRequire('win32', {
|
||||
read,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue