mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 12:45:38 +00:00
refactored getCollectionJsonFromPathname function and added tests
This commit is contained in:
@@ -12,7 +12,7 @@ const { rpad } = require('../utils/common');
|
||||
const { bruToJson, getOptions, collectionBruToJson } = require('../utils/bru');
|
||||
const { dotenvToJson } = require('@usebruno/lang');
|
||||
const constants = require('../constants');
|
||||
const { findItemInCollection, getAllRequestsInFolder } = require('../utils/collection');
|
||||
const { findItemInCollection, getAllRequestsInFolder, createCollectionJsonFromPathname } = require('../utils/collection');
|
||||
const command = 'run [filename]';
|
||||
const desc = 'Run a request';
|
||||
|
||||
@@ -76,87 +76,6 @@ const printRunSummary = (results) => {
|
||||
}
|
||||
};
|
||||
|
||||
const createCollectionFromPath = (collectionPath) => {
|
||||
const environmentsPath = path.join(collectionPath, `environments`);
|
||||
const getFilesInOrder = (collectionPath) => {
|
||||
let collection = {
|
||||
pathname: collectionPath
|
||||
};
|
||||
const traverse = (currentPath) => {
|
||||
const filesInCurrentDir = fs.readdirSync(currentPath);
|
||||
|
||||
if (currentPath.includes('node_modules')) {
|
||||
return;
|
||||
}
|
||||
const currentDirItems = [];
|
||||
for (const file of filesInCurrentDir) {
|
||||
const filePath = path.join(currentPath, file);
|
||||
const stats = fs.lstatSync(filePath);
|
||||
if (
|
||||
stats.isDirectory() &&
|
||||
filePath !== environmentsPath &&
|
||||
!filePath.startsWith('.git') &&
|
||||
!filePath.startsWith('node_modules')
|
||||
) {
|
||||
let folderItem = { name: file, pathname: filePath, type: 'folder', items: traverse(filePath) }
|
||||
const folderBruJson = getFolderRoot(filePath);
|
||||
if (folderBruJson) {
|
||||
folderItem.root = folderBruJson;
|
||||
folderItem.seq = folderBruJson.meta.seq;
|
||||
}
|
||||
currentDirItems.push(folderItem);
|
||||
}
|
||||
}
|
||||
|
||||
for (const file of filesInCurrentDir) {
|
||||
if (['collection.bru', 'folder.bru'].includes(file)) {
|
||||
continue;
|
||||
}
|
||||
const filePath = path.join(currentPath, file);
|
||||
const stats = fs.lstatSync(filePath);
|
||||
|
||||
if (!stats.isDirectory() && path.extname(filePath) === '.bru') {
|
||||
const bruContent = fs.readFileSync(filePath, 'utf8');
|
||||
const requestItem = bruToJson(bruContent);
|
||||
currentDirItems.push({
|
||||
name: file,
|
||||
pathname: filePath,
|
||||
...requestItem
|
||||
});
|
||||
}
|
||||
}
|
||||
const sortedFolderItems = currentDirItems?.filter((iter) => iter.type === 'folder')?.sort((a, b) => a.seq - b.seq);
|
||||
const sortedRequestItems = currentDirItems?.filter((iter) => iter.type !== 'folder')?.sort((a, b) => a.seq - b.seq);
|
||||
return sortedFolderItems?.concat(sortedRequestItems);
|
||||
};
|
||||
collection.items = traverse(collectionPath);
|
||||
return collection;
|
||||
};
|
||||
return getFilesInOrder(collectionPath);
|
||||
};
|
||||
|
||||
const getCollectionRoot = (dir) => {
|
||||
const collectionRootPath = path.join(dir, 'collection.bru');
|
||||
const exists = fs.existsSync(collectionRootPath);
|
||||
if (!exists) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(collectionRootPath, 'utf8');
|
||||
return collectionBruToJson(content);
|
||||
};
|
||||
|
||||
const getFolderRoot = (dir) => {
|
||||
const folderRootPath = path.join(dir, 'folder.bru');
|
||||
const exists = fs.existsSync(folderRootPath);
|
||||
if (!exists) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(folderRootPath, 'utf8');
|
||||
return collectionBruToJson(content);
|
||||
};
|
||||
|
||||
const getJsSandboxRuntime = (sandbox) => {
|
||||
return sandbox === 'safe' ? 'quickjs' : 'vm2';
|
||||
};
|
||||
@@ -249,7 +168,10 @@ const builder = async (yargs) => {
|
||||
type:"number",
|
||||
description: "Delay between each requests (in miliseconds)"
|
||||
})
|
||||
|
||||
.option('collection-pathname', {
|
||||
type: "string",
|
||||
description: "Collection root pathname"
|
||||
})
|
||||
.example('$0 run request.bru', 'Run a request')
|
||||
.example('$0 run request.bru --env local', 'Run a request with the environment set to local')
|
||||
.example('$0 run folder', 'Run all requests in a folder')
|
||||
@@ -315,29 +237,15 @@ const handler = async function (argv) {
|
||||
reporterSkipAllHeaders,
|
||||
reporterSkipHeaders,
|
||||
clientCertConfig,
|
||||
delay
|
||||
delay,
|
||||
collectionPathname
|
||||
} = argv;
|
||||
const collectionPath = process.cwd();
|
||||
const collectionPath = collectionPathname || process.cwd();
|
||||
|
||||
// todo
|
||||
// right now, bru must be run from the root of the collection
|
||||
// will add support in the future to run it from anywhere inside the collection
|
||||
const brunoJsonPath = path.join(collectionPath, 'bruno.json');
|
||||
const brunoJsonExists = await exists(brunoJsonPath);
|
||||
if (!brunoJsonExists) {
|
||||
console.error(chalk.red(`You can run only at the root of a collection`));
|
||||
process.exit(constants.EXIT_STATUS.ERROR_NOT_IN_COLLECTION);
|
||||
}
|
||||
filename = path.join(collectionPath, filename);
|
||||
|
||||
const brunoConfigFile = fs.readFileSync(brunoJsonPath, 'utf8');
|
||||
const brunoConfig = JSON.parse(brunoConfigFile);
|
||||
const collectionRoot = getCollectionRoot(collectionPath);
|
||||
let collection = createCollectionFromPath(collectionPath);
|
||||
collection = {
|
||||
brunoConfig,
|
||||
root: collectionRoot,
|
||||
...collection
|
||||
}
|
||||
let collection = createCollectionJsonFromPathname(collectionPath);
|
||||
const { root: collectionRoot, brunoConfig } = collection;
|
||||
|
||||
if (clientCertConfig) {
|
||||
try {
|
||||
@@ -358,10 +266,10 @@ const handler = async function (argv) {
|
||||
}
|
||||
|
||||
if (clientCertConfigJson?.enabled && Array.isArray(clientCertConfigJson?.certs)) {
|
||||
if (brunoConfig.clientCertificates) {
|
||||
brunoConfig.clientCertificates.certs.push(...clientCertConfigJson.certs);
|
||||
if (clientCertificates) {
|
||||
clientCertificates.certs.push(...clientCertConfigJson.certs);
|
||||
} else {
|
||||
brunoConfig.clientCertificates = { certs: clientCertConfigJson.certs };
|
||||
clientCertificates = { certs: clientCertConfigJson.certs };
|
||||
}
|
||||
console.log(chalk.green(`Client certificates has been added`));
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,112 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { jsonToBruV2, envJsonToBruV2, jsonToCollectionBru } = require('@usebruno/lang');
|
||||
const { sanitizeName } = require('./filesystem');
|
||||
const { bruToJson, collectionBruToJson } = require('./bru');
|
||||
const constants = require('../constants');
|
||||
const chalk = require('chalk');
|
||||
|
||||
const createCollectionJsonFromPathname = (collectionPath) => {
|
||||
const environmentsPath = path.join(collectionPath, `environments`);
|
||||
|
||||
// get the collection bruno json config [<collection-path>/bruno.json]
|
||||
const brunoConfig = getCollectionBrunoJsonConfig(collectionPath);
|
||||
|
||||
// get the collection root [<collection-path>/collection.bru]
|
||||
const collectionRoot = getCollectionRoot(collectionPath);
|
||||
|
||||
// get the collection items recursively
|
||||
const traverse = (currentPath) => {
|
||||
const filesInCurrentDir = fs.readdirSync(currentPath);
|
||||
if (currentPath.includes('node_modules')) {
|
||||
return;
|
||||
}
|
||||
const currentDirItems = [];
|
||||
for (const file of filesInCurrentDir) {
|
||||
const filePath = path.join(currentPath, file);
|
||||
const stats = fs.lstatSync(filePath);
|
||||
if (stats.isDirectory()) {
|
||||
if (filePath === environmentsPath) continue;
|
||||
if (filePath.startsWith('.git') || filePath.startsWith('node_modules')) continue;
|
||||
|
||||
// get the folder root
|
||||
let folderItem = { name: file, pathname: filePath, type: 'folder', items: traverse(filePath) }
|
||||
const folderBruJson = getFolderRoot(filePath);
|
||||
if (folderBruJson) {
|
||||
folderItem.root = folderBruJson;
|
||||
folderItem.seq = folderBruJson.meta.seq;
|
||||
}
|
||||
currentDirItems.push(folderItem);
|
||||
}
|
||||
else {
|
||||
if (['collection.bru', 'folder.bru'].includes(file)) continue;
|
||||
if (path.extname(filePath) !== '.bru') continue;
|
||||
|
||||
// get the request item
|
||||
const bruContent = fs.readFileSync(filePath, 'utf8');
|
||||
const requestItem = bruToJson(bruContent);
|
||||
currentDirItems.push({
|
||||
name: file,
|
||||
pathname: filePath,
|
||||
...requestItem
|
||||
});
|
||||
}
|
||||
}
|
||||
let currentDirFolderItems = currentDirItems?.filter((iter) => iter.type === 'folder');
|
||||
let sortedFolderItems = currentDirFolderItems?.sort((a, b) => a.seq - b.seq);
|
||||
|
||||
let currentDirRequestItems = currentDirItems?.filter((iter) => iter.type !== 'folder');
|
||||
let sortedRequestItems = currentDirRequestItems?.sort((a, b) => a.seq - b.seq);
|
||||
|
||||
return sortedFolderItems?.concat(sortedRequestItems);
|
||||
};
|
||||
let collectionItems = traverse(collectionPath);
|
||||
|
||||
let collection = {
|
||||
brunoConfig,
|
||||
root: collectionRoot,
|
||||
pathname: collectionPath,
|
||||
items: collectionItems
|
||||
}
|
||||
|
||||
return collection;
|
||||
};
|
||||
|
||||
const getCollectionBrunoJsonConfig = (dir) => {
|
||||
// right now, bru must be run from the root of the collection
|
||||
// will add support in the future to run it from anywhere inside the collection
|
||||
const brunoJsonPath = path.join(dir, 'bruno.json');
|
||||
const brunoJsonExists = fs.existsSync(brunoJsonPath);
|
||||
if (!brunoJsonExists) {
|
||||
console.error(chalk.red(`You can run only at the root of a collection`));
|
||||
process.exit(constants.EXIT_STATUS.ERROR_NOT_IN_COLLECTION);
|
||||
}
|
||||
|
||||
const brunoConfigFile = fs.readFileSync(brunoJsonPath, 'utf8');
|
||||
const brunoConfig = JSON.parse(brunoConfigFile);
|
||||
return brunoConfig;
|
||||
}
|
||||
|
||||
const getCollectionRoot = (dir) => {
|
||||
const collectionRootPath = path.join(dir, 'collection.bru');
|
||||
const exists = fs.existsSync(collectionRootPath);
|
||||
if (!exists) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(collectionRootPath, 'utf8');
|
||||
return collectionBruToJson(content);
|
||||
};
|
||||
|
||||
const getFolderRoot = (dir) => {
|
||||
const folderRootPath = path.join(dir, 'folder.bru');
|
||||
const exists = fs.existsSync(folderRootPath);
|
||||
if (!exists) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(folderRootPath, 'utf8');
|
||||
return collectionBruToJson(content);
|
||||
};
|
||||
|
||||
const mergeHeaders = (collection, request, requestTreePath) => {
|
||||
let headers = new Map();
|
||||
@@ -355,7 +461,10 @@ const processCollectionItems = async (items = [], currentPath) => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
createCollectionJsonFromPathname,
|
||||
mergeHeaders,
|
||||
mergeVars,
|
||||
mergeScripts,
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
const path = require("node:path");
|
||||
const { describe, it, expect } = require('@jest/globals');
|
||||
const constants = require('../../src/constants');
|
||||
const { createCollectionJsonFromPathname } = require('../../src/utils/collection');
|
||||
|
||||
describe('create collection json from pathname', () => {
|
||||
it("should throw an error when the pathname is not a valid bruno collection root", () => {
|
||||
const invalidCollectionPathname = path.join(__dirname, './fixtures/collection-invalid');
|
||||
jest.spyOn(console, 'error').mockImplementation(() => { });
|
||||
let mockProcessExit = jest.spyOn(process, 'exit').mockImplementation((code) => { throw new Error(code); });
|
||||
try { createCollectionJsonFromPathname(invalidCollectionPathname); } catch {}
|
||||
expect(mockProcessExit).toHaveBeenCalledWith(constants.EXIT_STATUS.ERROR_NOT_IN_COLLECTION);
|
||||
jest.restoreAllMocks();
|
||||
})
|
||||
|
||||
it("creates a bruno collection json from the collection bru files", () => {
|
||||
const collectionPathname = path.join(__dirname, './fixtures/collection-json-from-pathname/collection');
|
||||
const outputCollectionJson = createCollectionJsonFromPathname(collectionPathname);
|
||||
|
||||
let c = outputCollectionJson;
|
||||
expect(c).toBeDefined();
|
||||
|
||||
/*
|
||||
collection bruno.json
|
||||
*/
|
||||
|
||||
expect(c).toHaveProperty('brunoConfig.version', "1");
|
||||
expect(c).toHaveProperty('brunoConfig.name', 'collection');
|
||||
expect(c).toHaveProperty('brunoConfig.type', 'collection');
|
||||
expect(c).toHaveProperty('brunoConfig.ignore', ["node_modules", ".git"]);
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.enabled', false);
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.protocol', 'http');
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.hostname', '<proxy-hostname>');
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.port', 3000);
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.auth.enabled', false);
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.auth.username', '<user-name>');
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.auth.password', '<password>');
|
||||
expect(c).toHaveProperty('brunoConfig.proxy.bypassProxy', '');
|
||||
expect(c).toHaveProperty('brunoConfig.scripts.moduleWhitelist', ['crypto', 'buffer']);
|
||||
expect(c).toHaveProperty('brunoConfig.scripts.filesystemAccess.allow', true);
|
||||
expect(c).toHaveProperty('brunoConfig.clientCertificates.enabled', true);
|
||||
expect(c).toHaveProperty('brunoConfig.clientCertificates.certs', []);
|
||||
|
||||
/*
|
||||
collection pathname
|
||||
*/
|
||||
|
||||
expect(c).toHaveProperty('pathname', collectionPathname);
|
||||
|
||||
|
||||
/*
|
||||
collection root
|
||||
*/
|
||||
|
||||
// headers
|
||||
expect(c).toHaveProperty('root.request.headers[0].name', 'collection_header');
|
||||
expect(c).toHaveProperty('root.request.headers[0].value', 'collection_header_value');
|
||||
expect(c).toHaveProperty('root.request.headers[0].enabled', true);
|
||||
// auth
|
||||
expect(c).toHaveProperty('root.request.auth.mode', 'basic');
|
||||
expect(c).toHaveProperty('root.request.auth.basic.username', 'username');
|
||||
expect(c).toHaveProperty('root.request.auth.basic.password', 'password');
|
||||
// pre-request scripts
|
||||
expect(c).toHaveProperty('root.request.script.req', 'const collectionPreRequestScript = true;');
|
||||
// collection root - post-response scripts
|
||||
expect(c).toHaveProperty('root.request.script.res', 'const collectionPostResponseScript = true;');
|
||||
// pre-request vars
|
||||
expect(c).toHaveProperty('root.request.vars.req[0].name', 'collection_pre_var');
|
||||
expect(c).toHaveProperty('root.request.vars.req[0].value', 'collection_pre_var_value');
|
||||
expect(c).toHaveProperty('root.request.vars.req[0].enabled', true);
|
||||
// post-response vars
|
||||
expect(c).toHaveProperty('root.request.vars.res[0].name', 'collection_post_var');
|
||||
expect(c).toHaveProperty('root.request.vars.res[0].value', 'collection_post_var_value');
|
||||
expect(c).toHaveProperty('root.request.vars.res[0].enabled', true);
|
||||
// tests
|
||||
expect(c).toHaveProperty('root.request.tests', 'test(\"collection level script\", function() {\n expect(\"test\").to.equal(\"test\");\n});');
|
||||
|
||||
|
||||
/*
|
||||
collection items names and sequences
|
||||
*/
|
||||
|
||||
// <collection-root>/folder_2
|
||||
expect(c).toHaveProperty('items[0].type', 'folder');
|
||||
expect(c).toHaveProperty('items[0].name', 'folder_2');
|
||||
expect(c).toHaveProperty('items[0].seq', 1);
|
||||
|
||||
// <collection-root>/folder_2/request_1
|
||||
expect(c).toHaveProperty('items[0].items[0].name', 'request_1');
|
||||
expect(c).toHaveProperty('items[0].items[0].seq', 1);
|
||||
|
||||
// <collection-root>/folder_2/request_3
|
||||
expect(c).toHaveProperty('items[0].items[1].name', 'request_3');
|
||||
expect(c).toHaveProperty('items[0].items[1].seq', 2);
|
||||
|
||||
// <collection-root>/folder_2/request_2
|
||||
expect(c).toHaveProperty('items[0].items[2].name', 'request_2');
|
||||
expect(c).toHaveProperty('items[0].items[2].seq', 3);
|
||||
|
||||
// <collection-root>/folder_1
|
||||
expect(c).toHaveProperty('items[1].type', 'folder');
|
||||
expect(c).toHaveProperty('items[1].name', 'folder_1');
|
||||
expect(c).toHaveProperty('items[1].seq', 5);
|
||||
|
||||
// <collection-root>/folder_1/folder_2
|
||||
expect(c).toHaveProperty('items[1].items[0].name', 'folder_2');
|
||||
expect(c).toHaveProperty('items[1].items[0].seq', 1);
|
||||
|
||||
// <collection-root>/folder_1/folder_2/request_3
|
||||
expect(c).toHaveProperty('items[1].items[0].items[0].name', 'request_3');
|
||||
expect(c).toHaveProperty('items[1].items[0].items[0].seq', 1);
|
||||
|
||||
// <collection-root>/folder_1/folder_2/request_1
|
||||
expect(c).toHaveProperty('items[1].items[0].items[1].name', 'request_1');
|
||||
expect(c).toHaveProperty('items[1].items[0].items[1].seq', 2);
|
||||
|
||||
// <collection-root>/folder_1/folder_2/request_2
|
||||
expect(c).toHaveProperty('items[1].items[0].items[2].name', 'request_2');
|
||||
expect(c).toHaveProperty('items[1].items[0].items[2].seq', 3);
|
||||
|
||||
// <collection-root>/folder_1/folder_1
|
||||
expect(c).toHaveProperty('items[1].items[1].name', 'folder_1');
|
||||
expect(c).toHaveProperty('items[1].items[1].seq', 2);
|
||||
|
||||
// <collection-root>/folder_1/folder_1/request_3
|
||||
expect(c).toHaveProperty('items[1].items[1].items[0].name', 'request_3');
|
||||
expect(c).toHaveProperty('items[1].items[1].items[0].seq', 1);
|
||||
|
||||
// <collection-root>/folder_1/folder_1/request_2
|
||||
expect(c).toHaveProperty('items[1].items[1].items[1].name', 'request_2');
|
||||
expect(c).toHaveProperty('items[1].items[1].items[1].seq', 2);
|
||||
|
||||
// <collection-root>/folder_1/folder_1/request_1
|
||||
expect(c).toHaveProperty('items[1].items[1].items[2].name', 'request_1');
|
||||
expect(c).toHaveProperty('items[1].items[1].items[2].seq', 3);
|
||||
|
||||
// <collection-root>/folder_1/request_1
|
||||
expect(c).toHaveProperty('items[1].items[2].name', 'request_1');
|
||||
expect(c).toHaveProperty('items[1].items[2].seq', 3);
|
||||
|
||||
// <collection-root>/folder_1/request_3
|
||||
expect(c).toHaveProperty('items[1].items[3].name', 'request_3');
|
||||
expect(c).toHaveProperty('items[1].items[3].seq', 4);
|
||||
|
||||
// <collection-root>/folder_1/request_2
|
||||
expect(c).toHaveProperty('items[1].items[4].name', 'request_2');
|
||||
expect(c).toHaveProperty('items[1].items[4].seq', 5);
|
||||
|
||||
// <collection-root>/request_2
|
||||
expect(c).toHaveProperty('items[2].name', 'request_3');
|
||||
expect(c).toHaveProperty('items[2].seq', 2);
|
||||
|
||||
// <collection-root>/request_3
|
||||
expect(c).toHaveProperty('items[3].name', 'request_1');
|
||||
expect(c).toHaveProperty('items[3].seq', 3);
|
||||
|
||||
// <collection-root>/request_4
|
||||
expect(c).toHaveProperty('items[4].name', 'request_2');
|
||||
expect(c).toHaveProperty('items[4].seq', 4);
|
||||
|
||||
|
||||
/*
|
||||
collection request item - <collection-root>/request_4
|
||||
*/
|
||||
|
||||
// <collection-root>/request_4
|
||||
// headers
|
||||
expect(c).toHaveProperty('items[4].request.headers[0].name', 'request_header');
|
||||
expect(c).toHaveProperty('items[4].request.headers[0].value', 'request_header_value');
|
||||
expect(c).toHaveProperty('items[4].request.headers[0].enabled', true);
|
||||
// auth
|
||||
expect(c).toHaveProperty('items[4].request.auth.mode', 'basic');
|
||||
expect(c).toHaveProperty('items[4].request.auth.basic.username', 'username');
|
||||
expect(c).toHaveProperty('items[4].request.auth.basic.password', 'password');
|
||||
// pre-request scripts
|
||||
expect(c).toHaveProperty('items[4].request.script.req', 'const requestPreRequestScript = true;');
|
||||
// request items[4] - post-response scripts
|
||||
expect(c).toHaveProperty('items[4].request.script.res', 'const requestPostResponseScript = true;');
|
||||
// pre-request vars
|
||||
expect(c).toHaveProperty('items[4].request.vars.req[0].name', 'request_pre_var');
|
||||
expect(c).toHaveProperty('items[4].request.vars.req[0].value', 'request_pre_var_value');
|
||||
expect(c).toHaveProperty('items[4].request.vars.req[0].enabled', true);
|
||||
// post-response vars
|
||||
expect(c).toHaveProperty('items[4].request.vars.res[0].name', 'request_post_var');
|
||||
expect(c).toHaveProperty('items[4].request.vars.res[0].value', 'request_post_var_value');
|
||||
expect(c).toHaveProperty('items[4].request.vars.res[0].enabled', true);
|
||||
// tests
|
||||
expect(c).toHaveProperty('items[4].request.tests', 'test(\"request level script\", function() {\n expect(\"test\").to.equal(\"test\");\n});');
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "collection",
|
||||
"type": "collection",
|
||||
"ignore": [
|
||||
"node_modules",
|
||||
".git"
|
||||
],
|
||||
"proxy": {
|
||||
"enabled": false,
|
||||
"protocol": "http",
|
||||
"hostname": "<proxy-hostname>",
|
||||
"port": 3000,
|
||||
"auth": {
|
||||
"enabled": false,
|
||||
"username": "<user-name>",
|
||||
"password": "<password>"
|
||||
},
|
||||
"bypassProxy": ""
|
||||
},
|
||||
"scripts": {
|
||||
"moduleWhitelist": ["crypto", "buffer"],
|
||||
"filesystemAccess": {
|
||||
"allow": true
|
||||
}
|
||||
},
|
||||
"clientCertificates": {
|
||||
"enabled": true,
|
||||
"certs": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
headers {
|
||||
collection_header: collection_header_value
|
||||
}
|
||||
|
||||
auth {
|
||||
mode: basic
|
||||
}
|
||||
|
||||
auth:basic {
|
||||
username: username
|
||||
password: password
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
collection_pre_var: collection_pre_var_value
|
||||
}
|
||||
|
||||
vars:post-response {
|
||||
collection_post_var: collection_post_var_value
|
||||
}
|
||||
|
||||
script:pre-request {
|
||||
const collectionPreRequestScript = true;
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
const collectionPostResponseScript = true;
|
||||
}
|
||||
|
||||
tests {
|
||||
test("collection level script", function() {
|
||||
expect("test").to.equal("test");
|
||||
});
|
||||
}
|
||||
|
||||
docs {
|
||||
# docs
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
meta {
|
||||
name: folder_1
|
||||
seq: 5
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
meta {
|
||||
name: folder_1
|
||||
seq: 2
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_1
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_2
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_3
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
meta {
|
||||
name: folder_2
|
||||
seq: 1
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_1
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_2
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_3
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_1
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_2
|
||||
type: http
|
||||
seq: 5
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_3
|
||||
type: http
|
||||
seq: 4
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
meta {
|
||||
name: folder_2
|
||||
seq: 1
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_1
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_2
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_3
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_1
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
meta {
|
||||
name: request_2
|
||||
type: http
|
||||
seq: 4
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com/:request_path_param?request_query_param=request_query_param_value
|
||||
body: text
|
||||
auth: basic
|
||||
}
|
||||
|
||||
params:query {
|
||||
request_query_param: request_query_param_value
|
||||
}
|
||||
|
||||
params:path {
|
||||
request_path_param: request_path_param_value
|
||||
}
|
||||
|
||||
headers {
|
||||
request_header: request_header_value
|
||||
}
|
||||
|
||||
auth:basic {
|
||||
username: username
|
||||
password: password
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
request_pre_var: request_pre_var_value
|
||||
}
|
||||
|
||||
vars:post-response {
|
||||
request_post_var: request_post_var_value
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
script:pre-request {
|
||||
const requestPreRequestScript = true;
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
const requestPostResponseScript = true;
|
||||
}
|
||||
|
||||
tests {
|
||||
test("request level script", function() {
|
||||
expect("test").to.equal("test");
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
meta {
|
||||
name: request_3
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://echo.usebruno.com
|
||||
body: text
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:text {
|
||||
ping
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
}
|
||||
|
||||
tests {
|
||||
test("should return plain text", function() {
|
||||
const data = res.getBody();
|
||||
expect(res.getBody()).to.eql("ping");
|
||||
});
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user