mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-21 12:33:34 +02:00
revert pr #252
This commit is contained in:
parent
5e2640fe73
commit
744abe585c
@ -4,13 +4,12 @@ const fs = require('fs');
|
|||||||
const { forOwn, each, extend, get } = require('lodash');
|
const { forOwn, each, extend, get } = require('lodash');
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const https = require('https');
|
||||||
const prepareRequest = require('./prepare-request');
|
const prepareRequest = require('./prepare-request');
|
||||||
const interpolateVars = require('./interpolate-vars');
|
const interpolateVars = require('./interpolate-vars');
|
||||||
const { ScriptRuntime, TestRuntime, VarsRuntime, AssertRuntime } = require('@usebruno/js');
|
const { ScriptRuntime, TestRuntime, VarsRuntime, AssertRuntime } = require('@usebruno/js');
|
||||||
const { stripExtension } = require('../utils/filesystem');
|
const { stripExtension } = require('../utils/filesystem');
|
||||||
const { getOptions } = require('../utils/bru');
|
const { getOptions } = require('../utils/bru');
|
||||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
|
||||||
const https = require('https');
|
|
||||||
|
|
||||||
const runSingleRequest = async function (
|
const runSingleRequest = async function (
|
||||||
filename,
|
filename,
|
||||||
@ -66,6 +65,31 @@ 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
|
// interpolate variables inside request
|
||||||
interpolateVars(request, envVariables, collectionVariables, processEnvVars);
|
interpolateVars(request, envVariables, collectionVariables, processEnvVars);
|
||||||
|
|
||||||
@ -87,30 +111,7 @@ const runSingleRequest = async function (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set proxy if enabled
|
if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||||
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
|
|
||||||
);
|
|
||||||
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
|
||||||
request.httpsAgent = new https.Agent({
|
request.httpsAgent = new https.Agent({
|
||||||
...httpsAgentRequestFields
|
...httpsAgentRequestFields
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,6 @@ const { sortFolder, getAllRequestsInFolderRecursively } = require('./helper');
|
|||||||
const { getPreferences } = require('../../store/preferences');
|
const { getPreferences } = require('../../store/preferences');
|
||||||
const { getProcessEnvVars } = require('../../store/process-env');
|
const { getProcessEnvVars } = require('../../store/process-env');
|
||||||
const { getBrunoConfig } = require('../../store/bruno-config');
|
const { getBrunoConfig } = require('../../store/bruno-config');
|
||||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
|
||||||
|
|
||||||
// override the default escape function to prevent escaping
|
// override the default escape function to prevent escaping
|
||||||
Mustache.escape = function (value) {
|
Mustache.escape = function (value) {
|
||||||
@ -166,6 +165,32 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
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);
|
interpolateVars(request, envVars, collectionVariables, processEnvVars);
|
||||||
|
|
||||||
// stringify the request url encoded params
|
// stringify the request url encoded params
|
||||||
@ -209,31 +234,7 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// proxy configuration
|
if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||||
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
|
|
||||||
);
|
|
||||||
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
|
||||||
request.httpsAgent = new https.Agent({
|
request.httpsAgent = new https.Agent({
|
||||||
...httpsAgentRequestFields
|
...httpsAgentRequestFields
|
||||||
});
|
});
|
||||||
@ -597,6 +598,32 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
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
|
// interpolate variables inside request
|
||||||
interpolateVars(request, envVars, collectionVariables, processEnvVars);
|
interpolateVars(request, envVars, collectionVariables, processEnvVars);
|
||||||
|
|
||||||
@ -617,30 +644,7 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
const preferences = getPreferences();
|
const preferences = getPreferences();
|
||||||
const sslVerification = get(preferences, 'request.sslVerification', true);
|
const sslVerification = get(preferences, 'request.sslVerification', true);
|
||||||
|
|
||||||
// proxy configuration
|
if (!sslVerification) {
|
||||||
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
|
|
||||||
});
|
|
||||||
} else if (!sslVerification) {
|
|
||||||
request.httpsAgent = new https.Agent({
|
request.httpsAgent = new https.Agent({
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user