From 0f211131b15ac1acf49e0032a98af3567af28cd0 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 28 Sep 2023 10:20:31 +0530 Subject: [PATCH] feat(#224): proxy config support in collection runner --- .../bruno-electron/src/ipc/network/index.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index aea3859ac..20f35b4c9 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -165,6 +165,7 @@ const registerNetworkIpc = (mainWindow) => { }); } + // proxy configuration const brunoConfig = getBrunoConfig(collectionUid); const proxyEnabled = get(brunoConfig, 'proxy.enabled', false); if (proxyEnabled) { @@ -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 interpolateVars(request, envVars, collectionVariables, processEnvVars);