forked from extern/bruno
Merge branch 'usebruno:main' into main
This commit is contained in:
commit
80414d751d
@ -15,6 +15,7 @@ import 'tailwindcss/dist/tailwind.min.css';
|
||||
import 'codemirror/lib/codemirror.css';
|
||||
import 'graphiql/graphiql.min.css';
|
||||
import 'react-tooltip/dist/react-tooltip.css';
|
||||
import '@usebruno/graphql-docs/dist/esm/index.css';
|
||||
|
||||
function SafeHydrate({ children }) {
|
||||
return <div suppressHydrationWarning>{typeof window === 'undefined' ? null : children}</div>;
|
||||
|
@ -33,6 +33,8 @@
|
||||
"form-data": "^4.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"handlebars": "^4.7.8",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.2",
|
||||
"inquirer": "^9.1.4",
|
||||
"lodash": "^4.17.21",
|
||||
"mustache": "^4.2.0",
|
||||
|
@ -4,13 +4,14 @@ const decomment = require('decomment');
|
||||
const fs = require('fs');
|
||||
const { forOwn, each, extend, get } = require('lodash');
|
||||
const FormData = require('form-data');
|
||||
const axios = require('axios');
|
||||
const https = require('https');
|
||||
const prepareRequest = require('./prepare-request');
|
||||
const interpolateVars = require('./interpolate-vars');
|
||||
const { ScriptRuntime, TestRuntime, VarsRuntime, AssertRuntime } = require('@usebruno/js');
|
||||
const { stripExtension } = require('../utils/filesystem');
|
||||
const { getOptions } = require('../utils/bru');
|
||||
const https = require('https');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const { HttpProxyAgent } = require('http-proxy-agent');
|
||||
const { makeAxiosInstance } = require('../utils/axios-instance');
|
||||
|
||||
const runSingleRequest = async function (
|
||||
@ -67,31 +68,6 @@ const runSingleRequest = async function (
|
||||
);
|
||||
}
|
||||
|
||||
// set proxy if enabled
|
||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||
if (proxyEnabled) {
|
||||
const proxyProtocol = get(brunoConfig, 'proxy.protocol');
|
||||
const proxyHostname = get(brunoConfig, 'proxy.hostname');
|
||||
const proxyPort = get(brunoConfig, 'proxy.port');
|
||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||
|
||||
const proxyConfig = {
|
||||
protocol: proxyProtocol,
|
||||
hostname: proxyHostname,
|
||||
port: proxyPort
|
||||
};
|
||||
if (proxyAuthEnabled) {
|
||||
const proxyAuthUsername = get(brunoConfig, 'proxy.auth.username');
|
||||
const proxyAuthPassword = get(brunoConfig, 'proxy.auth.password');
|
||||
proxyConfig.auth = {
|
||||
username: proxyAuthUsername,
|
||||
password: proxyAuthPassword
|
||||
};
|
||||
}
|
||||
|
||||
request.proxy = proxyConfig;
|
||||
}
|
||||
|
||||
// interpolate variables inside request
|
||||
interpolateVars(request, envVariables, collectionVariables, processEnvVars);
|
||||
|
||||
@ -113,7 +89,32 @@ const runSingleRequest = async function (
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||
// set proxy if enabled
|
||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||
if (proxyEnabled) {
|
||||
const proxyProtocol = get(brunoConfig, 'proxy.protocol');
|
||||
const proxyHostname = get(brunoConfig, 'proxy.hostname');
|
||||
const proxyPort = get(brunoConfig, 'proxy.port');
|
||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||
|
||||
let proxy;
|
||||
|
||||
if (proxyAuthEnabled) {
|
||||
const proxyAuthUsername = get(brunoConfig, 'proxy.auth.username');
|
||||
const proxyAuthPassword = get(brunoConfig, 'proxy.auth.password');
|
||||
|
||||
proxy = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
||||
} else {
|
||||
proxy = `${proxyProtocol}://${proxyHostname}:${proxyPort}`;
|
||||
}
|
||||
|
||||
request.httpsAgent = new HttpsProxyAgent(
|
||||
proxy,
|
||||
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
||||
);
|
||||
|
||||
request.httpAgent = new HttpProxyAgent(proxy);
|
||||
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||
request.httpsAgent = new https.Agent({
|
||||
...httpsAgentRequestFields
|
||||
});
|
||||
@ -165,7 +166,10 @@ const runSingleRequest = async function (
|
||||
}
|
||||
}
|
||||
|
||||
console.log(chalk.green(stripExtension(filename)) + chalk.dim(` (${response.status} ${response.statusText}) - ${responseTime} ms`));
|
||||
console.log(
|
||||
chalk.green(stripExtension(filename)) +
|
||||
chalk.dim(` (${response.status} ${response.statusText}) - ${responseTime} ms`)
|
||||
);
|
||||
|
||||
// run post-response vars
|
||||
const postResponseVars = get(bruJson, 'request.vars.res');
|
||||
|
@ -33,6 +33,7 @@
|
||||
"fs-extra": "^10.1.0",
|
||||
"graphql": "^16.6.0",
|
||||
"handlebars": "^4.7.8",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.2",
|
||||
"is-valid-path": "^0.1.1",
|
||||
"lodash": "^4.17.21",
|
||||
|
@ -16,6 +16,8 @@ const { sortFolder, getAllRequestsInFolderRecursively } = require('./helper');
|
||||
const { getPreferences } = require('../../store/preferences');
|
||||
const { getProcessEnvVars } = require('../../store/process-env');
|
||||
const { getBrunoConfig } = require('../../store/bruno-config');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const { HttpProxyAgent } = require('http-proxy-agent');
|
||||
const { makeAxiosInstance } = require('./axios-instance');
|
||||
const { addAwsV4Interceptor, resolveCredentials } = require('./awsv4auth-helper');
|
||||
|
||||
@ -171,31 +173,6 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
});
|
||||
}
|
||||
|
||||
// proxy configuration
|
||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||
if (proxyEnabled) {
|
||||
const proxyProtocol = get(brunoConfig, 'proxy.protocol');
|
||||
const proxyHostname = get(brunoConfig, 'proxy.hostname');
|
||||
const proxyPort = get(brunoConfig, 'proxy.port');
|
||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||
|
||||
const proxyConfig = {
|
||||
protocol: proxyProtocol,
|
||||
hostname: proxyHostname,
|
||||
port: proxyPort
|
||||
};
|
||||
if (proxyAuthEnabled) {
|
||||
const proxyAuthUsername = get(brunoConfig, 'proxy.auth.username');
|
||||
const proxyAuthPassword = get(brunoConfig, 'proxy.auth.password');
|
||||
proxyConfig.auth = {
|
||||
username: proxyAuthUsername,
|
||||
password: proxyAuthPassword
|
||||
};
|
||||
}
|
||||
|
||||
request.proxy = proxyConfig;
|
||||
}
|
||||
|
||||
interpolateVars(request, envVars, collectionVariables, processEnvVars);
|
||||
|
||||
// stringify the request url encoded params
|
||||
@ -239,7 +216,33 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||
// proxy configuration
|
||||
const brunoConfig = getBrunoConfig(collectionUid);
|
||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||
if (proxyEnabled) {
|
||||
const proxyProtocol = get(brunoConfig, 'proxy.protocol');
|
||||
const proxyHostname = get(brunoConfig, 'proxy.hostname');
|
||||
const proxyPort = get(brunoConfig, 'proxy.port');
|
||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||
|
||||
let proxy;
|
||||
|
||||
if (proxyAuthEnabled) {
|
||||
const proxyAuthUsername = get(brunoConfig, 'proxy.auth.username');
|
||||
const proxyAuthPassword = get(brunoConfig, 'proxy.auth.password');
|
||||
|
||||
proxy = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
||||
} else {
|
||||
proxy = `${proxyProtocol}://${proxyHostname}:${proxyPort}`;
|
||||
}
|
||||
|
||||
request.httpsAgent = new HttpsProxyAgent(
|
||||
proxy,
|
||||
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
||||
);
|
||||
|
||||
request.httpAgent = new HttpProxyAgent(proxy);
|
||||
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||
request.httpsAgent = new https.Agent({
|
||||
...httpsAgentRequestFields
|
||||
});
|
||||
@ -628,31 +631,6 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
});
|
||||
}
|
||||
|
||||
// proxy configuration
|
||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||
if (proxyEnabled) {
|
||||
const proxyProtocol = get(brunoConfig, 'proxy.protocol');
|
||||
const proxyHostname = get(brunoConfig, 'proxy.hostname');
|
||||
const proxyPort = get(brunoConfig, 'proxy.port');
|
||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||
|
||||
const proxyConfig = {
|
||||
protocol: proxyProtocol,
|
||||
hostname: proxyHostname,
|
||||
port: proxyPort
|
||||
};
|
||||
if (proxyAuthEnabled) {
|
||||
const proxyAuthUsername = get(brunoConfig, 'proxy.auth.username');
|
||||
const proxyAuthPassword = get(brunoConfig, 'proxy.auth.password');
|
||||
proxyConfig.auth = {
|
||||
username: proxyAuthUsername,
|
||||
password: proxyAuthPassword
|
||||
};
|
||||
}
|
||||
|
||||
request.proxy = proxyConfig;
|
||||
}
|
||||
|
||||
// interpolate variables inside request
|
||||
interpolateVars(request, envVars, collectionVariables, processEnvVars);
|
||||
|
||||
@ -673,7 +651,32 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
const preferences = getPreferences();
|
||||
const sslVerification = get(preferences, 'request.sslVerification', true);
|
||||
|
||||
if (!sslVerification) {
|
||||
// proxy configuration
|
||||
const brunoConfig = getBrunoConfig(collectionUid);
|
||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||
if (proxyEnabled) {
|
||||
const proxyProtocol = get(brunoConfig, 'proxy.protocol');
|
||||
const proxyHostname = get(brunoConfig, 'proxy.hostname');
|
||||
const proxyPort = get(brunoConfig, 'proxy.port');
|
||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||
|
||||
let proxy;
|
||||
|
||||
if (proxyAuthEnabled) {
|
||||
const proxyAuthUsername = get(brunoConfig, 'proxy.auth.username');
|
||||
const proxyAuthPassword = get(brunoConfig, 'proxy.auth.password');
|
||||
|
||||
proxy = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
||||
} else {
|
||||
proxy = `${proxyProtocol}://${proxyHostname}:${proxyPort}`;
|
||||
}
|
||||
|
||||
request.httpsAgent = new HttpsProxyAgent(proxy, {
|
||||
rejectUnauthorized: sslVerification
|
||||
});
|
||||
|
||||
request.httpAgent = new HttpProxyAgent(proxy);
|
||||
} else if (!sslVerification) {
|
||||
request.httpsAgent = new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user